ia64/xen-unstable

changeset 694:83565d4bb452

bitkeeper revision 1.408 (3f5774320u8HbDt_UW94uvftWnuvBA)

skbuff.c, dev.c, skbuff.h:
Fix transmit path for NICs which need a linearised skbuff.
author kaf24@scramble.cl.cam.ac.uk
date Thu Sep 04 17:19:46 2003 +0000 (2003-09-04)
parents 04b2915c1333
children c66f5e9d6427
files xen/include/xeno/skbuff.h xen/net/dev.c xen/net/skbuff.c
line diff
     1.1 --- a/xen/include/xeno/skbuff.h	Thu Sep 04 16:58:44 2003 +0000
     1.2 +++ b/xen/include/xeno/skbuff.h	Thu Sep 04 17:19:46 2003 +0000
     1.3 @@ -440,19 +440,20 @@ static inline struct sk_buff *dev_alloc_
     1.4      return __dev_alloc_skb(length, GFP_ATOMIC);
     1.5  }
     1.6  
     1.7 +#include <asm/domain_page.h>
     1.8 +
     1.9  static inline void *kmap_skb_frag(const skb_frag_t *frag)
    1.10  {
    1.11 -    return page_address(frag->page);
    1.12 +    return map_domain_mem(__pa(page_address(frag->page)));
    1.13  }
    1.14  
    1.15  static inline void kunmap_skb_frag(void *vaddr)
    1.16  {
    1.17 +    unmap_domain_mem(vaddr);
    1.18  }
    1.19  
    1.20  extern int skb_copy_bits(const struct sk_buff *skb, 
    1.21                           int offset, void *to, int len);
    1.22  extern void skb_init(void);
    1.23  
    1.24 -extern int skb_linearize(struct sk_buff *skn, int gfp_mask);
    1.25 -
    1.26  #endif	/* _LINUX_SKBUFF_H */
     2.1 --- a/xen/net/dev.c	Thu Sep 04 16:58:44 2003 +0000
     2.2 +++ b/xen/net/dev.c	Thu Sep 04 17:19:46 2003 +0000
     2.3 @@ -733,7 +733,7 @@ static void net_tx_action(unsigned long 
     2.4  {
     2.5      struct net_device *dev = the_dev;
     2.6      struct list_head *ent;
     2.7 -    struct sk_buff *skb;
     2.8 +    struct sk_buff *skb, *nskb;
     2.9      net_vif_t *vif;
    2.10      tx_shadow_entry_t *tx;
    2.11  
    2.12 @@ -794,7 +794,11 @@ static void net_tx_action(unsigned long 
    2.13  
    2.14          /* Is the NIC crap? */
    2.15          if ( !(dev->features & NETIF_F_SG) )
    2.16 -            skb_linearize(skb, GFP_KERNEL);
    2.17 +        {
    2.18 +            nskb = skb_copy(skb, GFP_KERNEL);
    2.19 +            kfree_skb(skb);
    2.20 +            skb = nskb;
    2.21 +        }
    2.22  
    2.23          /* Transmit should always work, or the queue would be stopped. */
    2.24          if ( dev->hard_start_xmit(skb, dev) != 0 )
     3.1 --- a/xen/net/skbuff.c	Thu Sep 04 16:58:44 2003 +0000
     3.2 +++ b/xen/net/skbuff.c	Thu Sep 04 17:19:46 2003 +0000
     3.3 @@ -430,57 +430,6 @@ struct sk_buff *skb_copy(const struct sk
     3.4      return n;
     3.5  }
     3.6  
     3.7 -/* Keep head the same: replace data */
     3.8 -int skb_linearize(struct sk_buff *skb, int gfp_mask)
     3.9 -{
    3.10 -	unsigned int size;
    3.11 -	u8 *data;
    3.12 -	long offset;
    3.13 -	int headerlen = skb->data - skb->head;
    3.14 -	int expand = (skb->tail+skb->data_len) - skb->end;
    3.15 -
    3.16 -	if (skb_shinfo(skb)->nr_frags == 0)
    3.17 -		return 0;
    3.18 -
    3.19 -	if (expand <= 0)
    3.20 -		expand = 0;
    3.21 -
    3.22 -	size = (skb->end - skb->head + expand);
    3.23 -	size = SKB_DATA_ALIGN(size);
    3.24 -	data = kmalloc(size + sizeof(struct skb_shared_info), gfp_mask);
    3.25 -	if (data == NULL)
    3.26 -		return -ENOMEM;
    3.27 -
    3.28 -	/* Copy entire thing */
    3.29 -	if (skb_copy_bits(skb, -headerlen, data, headerlen+skb->len))
    3.30 -		BUG();
    3.31 -
    3.32 -	/* Offset between the two in bytes */
    3.33 -	offset = data - skb->head;
    3.34 -
    3.35 -	/* Free old data. */
    3.36 -	skb_release_data(skb);
    3.37 -
    3.38 -	skb->head = data;
    3.39 -	skb->end  = data + size;
    3.40 -
    3.41 -	/* Set up new pointers */
    3.42 -	skb->h.raw += offset;
    3.43 -	skb->nh.raw += offset;
    3.44 -	skb->mac.raw += offset;
    3.45 -	skb->tail += offset;
    3.46 -	skb->data += offset;
    3.47 -
    3.48 -	skb->skb_type = SKB_NORMAL;
    3.49 -
    3.50 -	/* Set up shinfo */
    3.51 -	skb_shinfo(skb)->nr_frags = 0;
    3.52 -
    3.53 -	skb->tail += skb->data_len;
    3.54 -	skb->data_len = 0;
    3.55 -	return 0;
    3.56 -}
    3.57 -
    3.58  /* Copy some data bits from skb to kernel buffer. */
    3.59  
    3.60  int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len)