Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 4126
b: refs/heads/master
c: bc971de
h: refs/heads/master
v: v3
  • Loading branch information
Christoph Hellwig authored and David S. Miller committed Jul 5, 2005
1 parent 7328940 commit 1324fb4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 28 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2f36895aa774cf4d1c3d68921e0209e796b66600
refs/heads/master: bc971dee6ece1fd0d431948924becd9c50e7b778
42 changes: 16 additions & 26 deletions trunk/drivers/net/shaper.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,8 @@ static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct shaper *shaper = dev->priv;
struct sk_buff *ptr;

if (down_trylock(&shaper->sem))
return -1;


spin_lock(&shaper->lock);
ptr=shaper->sendq.prev;

/*
Expand Down Expand Up @@ -232,7 +230,7 @@ static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev)
shaper->stats.collisions++;
}
shaper_kick(shaper);
up(&shaper->sem);
spin_unlock(&shaper->lock);
return 0;
}

Expand Down Expand Up @@ -271,11 +269,9 @@ static void shaper_timer(unsigned long data)
{
struct shaper *shaper = (struct shaper *)data;

if (!down_trylock(&shaper->sem)) {
shaper_kick(shaper);
up(&shaper->sem);
} else
mod_timer(&shaper->timer, jiffies);
spin_lock(&shaper->lock);
shaper_kick(shaper);
spin_unlock(&shaper->lock);
}

/*
Expand Down Expand Up @@ -331,21 +327,6 @@ static void shaper_kick(struct shaper *shaper)
}


/*
* Flush the shaper queues on a closedown
*/

static void shaper_flush(struct shaper *shaper)
{
struct sk_buff *skb;

down(&shaper->sem);
while((skb=skb_dequeue(&shaper->sendq))!=NULL)
dev_kfree_skb(skb);
shaper_kick(shaper);
up(&shaper->sem);
}

/*
* Bring the interface up. We just disallow this until a
* bind.
Expand Down Expand Up @@ -375,7 +356,15 @@ static int shaper_open(struct net_device *dev)
static int shaper_close(struct net_device *dev)
{
struct shaper *shaper=dev->priv;
shaper_flush(shaper);
struct sk_buff *skb;

while ((skb = skb_dequeue(&shaper->sendq)) != NULL)
dev_kfree_skb(skb);

spin_lock_bh(&shaper->lock);
shaper_kick(shaper);
spin_unlock_bh(&shaper->lock);

del_timer_sync(&shaper->timer);
return 0;
}
Expand Down Expand Up @@ -576,6 +565,7 @@ static void shaper_init_priv(struct net_device *dev)
init_timer(&sh->timer);
sh->timer.function=shaper_timer;
sh->timer.data=(unsigned long)sh;
spin_lock_init(&sh->lock);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion trunk/include/linux/if_shaper.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct shaper
__u32 shapeclock;
unsigned long recovery; /* Time we can next clock a packet out on
an empty queue */
struct semaphore sem;
spinlock_t lock;
struct net_device_stats stats;
struct net_device *dev;
int (*hard_start_xmit) (struct sk_buff *skb,
Expand Down

0 comments on commit 1324fb4

Please sign in to comment.