Skip to content

Commit

Permalink
[NET]: Kill skb->list
Browse files Browse the repository at this point in the history
Remove the "list" member of struct sk_buff, as it is entirely
redundant.  All SKB list removal callers know which list the
SKB is on, so storing this in sk_buff does nothing other than
taking up some space.

Two tricky bits were SCTP, which I took care of, and two ATM
drivers which Francois Romieu <[email protected]> fixed
up.

Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Francois Romieu <[email protected]>
  • Loading branch information
davem330 authored and David S. Miller committed Aug 29, 2005
1 parent 6869c4d commit 8728b83
Show file tree
Hide file tree
Showing 29 changed files with 229 additions and 283 deletions.
157 changes: 74 additions & 83 deletions drivers/atm/nicstar.c

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions drivers/atm/nicstar.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,14 @@

#define NS_IOREMAP_SIZE 4096

#define BUF_SM 0x00000000 /* These two are used for push_rxbufs() */
#define BUF_LG 0x00000001 /* CMD, Write_FreeBufQ, LBUF bit */
/*
* BUF_XX distinguish the Rx buffers depending on their (small/large) size.
* BUG_SM and BUG_LG are both used by the driver and the device.
* BUF_NONE is only used by the driver.
*/
#define BUF_SM 0x00000000 /* These two are used for push_rxbufs() */
#define BUF_LG 0x00000001 /* CMD, Write_FreeBufQ, LBUF bit */
#define BUF_NONE 0xffffffff /* Software only: */

#define NS_HBUFSIZE 65568 /* Size of max. AAL5 PDU */
#define NS_MAX_IOVECS (2 + (65568 - NS_SMBUFSIZE) / \
Expand Down Expand Up @@ -684,6 +690,12 @@ enum ns_regs
/* Device driver structures ***************************************************/


struct ns_skb_cb {
u32 buf_type; /* BUF_SM/BUF_LG/BUF_NONE */
};

#define NS_SKB_CB(skb) ((struct ns_skb_cb *)((skb)->cb))

typedef struct tsq_info
{
void *org;
Expand Down
8 changes: 5 additions & 3 deletions drivers/atm/zatm.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,12 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
chan = (here[3] & uPD98401_AAL5_CHAN) >>
uPD98401_AAL5_CHAN_SHIFT;
if (chan < zatm_dev->chans && zatm_dev->rx_map[chan]) {
int pos = ZATM_VCC(vcc)->pool;

vcc = zatm_dev->rx_map[chan];
if (skb == zatm_dev->last_free[ZATM_VCC(vcc)->pool])
zatm_dev->last_free[ZATM_VCC(vcc)->pool] = NULL;
skb_unlink(skb);
if (skb == zatm_dev->last_free[pos])
zatm_dev->last_free[pos] = NULL;
skb_unlink(skb, zatm_dev->pool + pos);
}
else {
printk(KERN_ERR DEV_LABEL "(itf %d): RX indication "
Expand Down
8 changes: 4 additions & 4 deletions drivers/bluetooth/bfusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static int bfusb_send_bulk(struct bfusb *bfusb, struct sk_buff *skb)
if (err) {
BT_ERR("%s bulk tx submit failed urb %p err %d",
bfusb->hdev->name, urb, err);
skb_unlink(skb);
skb_unlink(skb, &bfusb->pending_q);
usb_free_urb(urb);
} else
atomic_inc(&bfusb->pending_tx);
Expand Down Expand Up @@ -212,7 +212,7 @@ static void bfusb_tx_complete(struct urb *urb, struct pt_regs *regs)

read_lock(&bfusb->lock);

skb_unlink(skb);
skb_unlink(skb, &bfusb->pending_q);
skb_queue_tail(&bfusb->completed_q, skb);

bfusb_tx_wakeup(bfusb);
Expand Down Expand Up @@ -253,7 +253,7 @@ static int bfusb_rx_submit(struct bfusb *bfusb, struct urb *urb)
if (err) {
BT_ERR("%s bulk rx submit failed urb %p err %d",
bfusb->hdev->name, urb, err);
skb_unlink(skb);
skb_unlink(skb, &bfusb->pending_q);
kfree_skb(skb);
usb_free_urb(urb);
}
Expand Down Expand Up @@ -398,7 +398,7 @@ static void bfusb_rx_complete(struct urb *urb, struct pt_regs *regs)
buf += len;
}

skb_unlink(skb);
skb_unlink(skb, &bfusb->pending_q);
kfree_skb(skb);

bfusb_rx_submit(bfusb, urb);
Expand Down
4 changes: 2 additions & 2 deletions drivers/ieee1394/ieee1394_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ static void handle_packet_response(struct hpsb_host *host, int tcode,
return;
}

__skb_unlink(skb, skb->list);
__skb_unlink(skb, &host->pending_packet_queue);

if (packet->state == hpsb_queued) {
packet->sendtime = jiffies;
Expand Down Expand Up @@ -989,7 +989,7 @@ void abort_timedouts(unsigned long __opaque)
packet = (struct hpsb_packet *)skb->data;

if (time_before(packet->sendtime + expire, jiffies)) {
__skb_unlink(skb, skb->list);
__skb_unlink(skb, &host->pending_packet_queue);
packet->state = hpsb_complete;
packet->ack_code = ACKX_TIMEOUT;
queue_packet_complete(packet);
Expand Down
2 changes: 1 addition & 1 deletion drivers/isdn/act2000/capi.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ handle_ack(act2000_card *card, act2000_chan *chan, __u8 blocknr) {
if ((((m->msg.data_b3_req.fakencci >> 8) & 0xff) == chan->ncci) &&
(m->msg.data_b3_req.blocknr == blocknr)) {
/* found corresponding DATA_B3_REQ */
skb_unlink(tmp);
skb_unlink(tmp, &card->ackq);
chan->queued -= m->msg.data_b3_req.datalen;
if (m->msg.data_b3_req.flags)
ret = m->msg.data_b3_req.datalen;
Expand Down
50 changes: 2 additions & 48 deletions drivers/net/shaper.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,52 +156,6 @@ static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev)

SHAPERCB(skb)->shapelen= shaper_clocks(shaper,skb);

#ifdef SHAPER_COMPLEX /* and broken.. */

while(ptr && ptr!=(struct sk_buff *)&shaper->sendq)
{
if(ptr->pri<skb->pri
&& jiffies - SHAPERCB(ptr)->shapeclock < SHAPER_MAXSLIP)
{
struct sk_buff *tmp=ptr->prev;

/*
* It goes before us therefore we slip the length
* of the new frame.
*/

SHAPERCB(ptr)->shapeclock+=SHAPERCB(skb)->shapelen;
SHAPERCB(ptr)->shapelatency+=SHAPERCB(skb)->shapelen;

/*
* The packet may have slipped so far back it
* fell off.
*/
if(SHAPERCB(ptr)->shapelatency > SHAPER_LATENCY)
{
skb_unlink(ptr);
dev_kfree_skb(ptr);
}
ptr=tmp;
}
else
break;
}
if(ptr==NULL || ptr==(struct sk_buff *)&shaper->sendq)
skb_queue_head(&shaper->sendq,skb);
else
{
struct sk_buff *tmp;
/*
* Set the packet clock out time according to the
* frames ahead. Im sure a bit of thought could drop
* this loop.
*/
for(tmp=skb_peek(&shaper->sendq); tmp!=NULL && tmp!=ptr; tmp=tmp->next)
SHAPERCB(skb)->shapeclock+=tmp->shapelen;
skb_append(ptr,skb);
}
#else
{
struct sk_buff *tmp;
/*
Expand All @@ -220,7 +174,7 @@ static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev)
} else
skb_queue_tail(&shaper->sendq, skb);
}
#endif

if(sh_debug)
printk("Frame queued.\n");
if(skb_queue_len(&shaper->sendq)>SHAPER_QLEN)
Expand Down Expand Up @@ -302,7 +256,7 @@ static void shaper_kick(struct shaper *shaper)
* Pull the frame and get interrupts back on.
*/

skb_unlink(skb);
skb_unlink(skb, &shaper->sendq);
if (shaper->recovery <
SHAPERCB(skb)->shapeclock + SHAPERCB(skb)->shapelen)
shaper->recovery = SHAPERCB(skb)->shapeclock + SHAPERCB(skb)->shapelen;
Expand Down
22 changes: 7 additions & 15 deletions drivers/net/wan/sdla_fr.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ void s508_s514_unlock(sdla_t *card, unsigned long *smp_flags);
void s508_s514_lock(sdla_t *card, unsigned long *smp_flags);

unsigned short calc_checksum (char *, int);
static int setup_fr_header(struct sk_buff** skb,
static int setup_fr_header(struct sk_buff *skb,
struct net_device* dev, char op_mode);


Expand Down Expand Up @@ -1372,7 +1372,7 @@ static int if_send(struct sk_buff* skb, struct net_device* dev)
/* Move the if_header() code to here. By inserting frame
* relay header in if_header() we would break the
* tcpdump and other packet sniffers */
chan->fr_header_len = setup_fr_header(&skb,dev,chan->common.usedby);
chan->fr_header_len = setup_fr_header(skb,dev,chan->common.usedby);
if (chan->fr_header_len < 0 ){
++chan->ifstats.tx_dropped;
++card->wandev.stats.tx_dropped;
Expand Down Expand Up @@ -1597,8 +1597,6 @@ static int setup_for_delayed_transmit(struct net_device* dev,
return 1;
}

skb_unlink(skb);

chan->transmit_length = len;
chan->delay_skb = skb;

Expand Down Expand Up @@ -4871,18 +4869,15 @@ static void unconfig_fr (sdla_t *card)
}
}

static int setup_fr_header(struct sk_buff **skb_orig, struct net_device* dev,
static int setup_fr_header(struct sk_buff *skb, struct net_device* dev,
char op_mode)
{
struct sk_buff *skb = *skb_orig;
fr_channel_t *chan=dev->priv;

if (op_mode == WANPIPE){

if (op_mode == WANPIPE) {
chan->fr_header[0]=Q922_UI;

switch (htons(skb->protocol)){

case ETH_P_IP:
chan->fr_header[1]=NLPID_IP;
break;
Expand All @@ -4894,16 +4889,14 @@ static int setup_fr_header(struct sk_buff **skb_orig, struct net_device* dev,
}

/* If we are in bridging mode, we must apply
* an Ethernet header */
if (op_mode == BRIDGE || op_mode == BRIDGE_NODE){


* an Ethernet header
*/
if (op_mode == BRIDGE || op_mode == BRIDGE_NODE) {
/* Encapsulate the packet as a bridged Ethernet frame. */
#ifdef DEBUG
printk(KERN_INFO "%s: encapsulating skb for frame relay\n",
dev->name);
#endif

chan->fr_header[0] = 0x03;
chan->fr_header[1] = 0x00;
chan->fr_header[2] = 0x80;
Expand All @@ -4916,7 +4909,6 @@ static int setup_fr_header(struct sk_buff **skb_orig, struct net_device* dev,
/* Yuck. */
skb->protocol = ETH_P_802_3;
return 8;

}

return 0;
Expand Down
21 changes: 10 additions & 11 deletions drivers/usb/net/usbnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -2903,19 +2903,18 @@ static struct net_device_stats *usbnet_get_stats (struct net_device *net)
* completion callbacks. 2.5 should have fixed those bugs...
*/

static void defer_bh (struct usbnet *dev, struct sk_buff *skb)
static void defer_bh(struct usbnet *dev, struct sk_buff *skb, struct sk_buff_head *list)
{
struct sk_buff_head *list = skb->list;
unsigned long flags;

spin_lock_irqsave (&list->lock, flags);
__skb_unlink (skb, list);
spin_unlock (&list->lock);
spin_lock (&dev->done.lock);
__skb_queue_tail (&dev->done, skb);
spin_lock_irqsave(&list->lock, flags);
__skb_unlink(skb, list);
spin_unlock(&list->lock);
spin_lock(&dev->done.lock);
__skb_queue_tail(&dev->done, skb);
if (dev->done.qlen == 1)
tasklet_schedule (&dev->bh);
spin_unlock_irqrestore (&dev->done.lock, flags);
tasklet_schedule(&dev->bh);
spin_unlock_irqrestore(&dev->done.lock, flags);
}

/* some work can't be done in tasklets, so we use keventd
Expand Down Expand Up @@ -3120,7 +3119,7 @@ static void rx_complete (struct urb *urb, struct pt_regs *regs)
break;
}

defer_bh (dev, skb);
defer_bh(dev, skb, &dev->rxq);

if (urb) {
if (netif_running (dev->net)
Expand Down Expand Up @@ -3490,7 +3489,7 @@ static void tx_complete (struct urb *urb, struct pt_regs *regs)

urb->dev = NULL;
entry->state = tx_done;
defer_bh (dev, skb);
defer_bh(dev, skb, &dev->txq);
}

/*-------------------------------------------------------------------------*/
Expand Down
16 changes: 5 additions & 11 deletions include/linux/skbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ struct sk_buff {
struct sk_buff *next;
struct sk_buff *prev;

struct sk_buff_head *list;
struct sock *sk;
struct timeval stamp;
struct net_device *dev;
Expand Down Expand Up @@ -597,7 +596,6 @@ static inline void __skb_queue_head(struct sk_buff_head *list,
{
struct sk_buff *prev, *next;

newsk->list = list;
list->qlen++;
prev = (struct sk_buff *)list;
next = prev->next;
Expand All @@ -622,7 +620,6 @@ static inline void __skb_queue_tail(struct sk_buff_head *list,
{
struct sk_buff *prev, *next;

newsk->list = list;
list->qlen++;
next = (struct sk_buff *)list;
prev = next->prev;
Expand Down Expand Up @@ -655,7 +652,6 @@ static inline struct sk_buff *__skb_dequeue(struct sk_buff_head *list)
next->prev = prev;
prev->next = next;
result->next = result->prev = NULL;
result->list = NULL;
}
return result;
}
Expand All @@ -664,32 +660,31 @@ static inline struct sk_buff *__skb_dequeue(struct sk_buff_head *list)
/*
* Insert a packet on a list.
*/
extern void skb_insert(struct sk_buff *old, struct sk_buff *newsk);
extern void skb_insert(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list);
static inline void __skb_insert(struct sk_buff *newsk,
struct sk_buff *prev, struct sk_buff *next,
struct sk_buff_head *list)
{
newsk->next = next;
newsk->prev = prev;
next->prev = prev->next = newsk;
newsk->list = list;
list->qlen++;
}

/*
* Place a packet after a given packet in a list.
*/
extern void skb_append(struct sk_buff *old, struct sk_buff *newsk);
static inline void __skb_append(struct sk_buff *old, struct sk_buff *newsk)
extern void skb_append(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list);
static inline void __skb_append(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list)
{
__skb_insert(newsk, old, old->next, old->list);
__skb_insert(newsk, old, old->next, list);
}

/*
* remove sk_buff from list. _Must_ be called atomically, and with
* the list known..
*/
extern void skb_unlink(struct sk_buff *skb);
extern void skb_unlink(struct sk_buff *skb, struct sk_buff_head *list);
static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list)
{
struct sk_buff *next, *prev;
Expand All @@ -698,7 +693,6 @@ static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list)
next = skb->next;
prev = skb->prev;
skb->next = skb->prev = NULL;
skb->list = NULL;
next->prev = prev;
prev->next = next;
}
Expand Down
3 changes: 0 additions & 3 deletions net/atm/ipcommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

void skb_migrate(struct sk_buff_head *from,struct sk_buff_head *to)
{
struct sk_buff *skb;
unsigned long flags;
struct sk_buff *skb_from = (struct sk_buff *) from;
struct sk_buff *skb_to = (struct sk_buff *) to;
Expand All @@ -47,8 +46,6 @@ void skb_migrate(struct sk_buff_head *from,struct sk_buff_head *to)
prev->next = skb_to;
to->prev->next = from->next;
to->prev = from->prev;
for (skb = from->next; skb != skb_to; skb = skb->next)
skb->list = to;
to->qlen += from->qlen;
spin_unlock(&to->lock);
from->prev = skb_from;
Expand Down
Loading

0 comments on commit 8728b83

Please sign in to comment.