ia64/xen-unstable

changeset 162:afaade366555

bitkeeper revision 1.22.1.13 (3e4cebfb6eonEmBxQR609x0DlVAf5Q)

updates to enable inter-domain communication. (this requires that the vif's be
mapped appropriately by dom0) but now works correctly. Secondly, guest now
dev_alloc_skbs the original way.
author akw27@boulderdash.cl.cam.ac.uk
date Fri Feb 14 13:15:39 2003 +0000 (2003-02-14)
parents 9d397996348f
children 2a4e70540c0d
files xen-2.4.16/drivers/net/tg3.c xen-2.4.16/drivers/net/tg3.h xen-2.4.16/include/asm-i386/pci.h xen-2.4.16/net/dev.c xen-2.4.16/net/skbuff.c xenolinux-2.4.16-sparse/arch/xeno/drivers/network/network.c xenolinux-2.4.16-sparse/include/linux/skbuff.h
line diff
     1.1 --- a/xen-2.4.16/drivers/net/tg3.c	Wed Feb 12 17:46:52 2003 +0000
     1.2 +++ b/xen-2.4.16/drivers/net/tg3.c	Fri Feb 14 13:15:39 2003 +0000
     1.3 @@ -4114,14 +4114,16 @@ static int tg3_reset_hw(struct tg3 *tp)
     1.4  		udelay(10);
     1.5  	}
     1.6  
     1.7 -	tw32(HOSTCC_RXCOL_TICKS, 0);
     1.8 -	tw32(HOSTCC_RXMAX_FRAMES, 1);
     1.9 -	tw32(HOSTCC_RXCOAL_TICK_INT, 0);
    1.10 -	tw32(HOSTCC_RXCOAL_MAXF_INT, 1);
    1.11 -	tw32(HOSTCC_TXCOL_TICKS, LOW_TXCOL_TICKS);
    1.12 -	tw32(HOSTCC_TXMAX_FRAMES, LOW_RXMAX_FRAMES);
    1.13 -	tw32(HOSTCC_TXCOAL_TICK_INT, 0);
    1.14 -	tw32(HOSTCC_TXCOAL_MAXF_INT, 0);
    1.15 +        // akw: I have set these all back to default coalescing values.
    1.16 +        
    1.17 +	tw32(HOSTCC_RXCOL_TICKS, DEFAULT_RXCOL_TICKS); //0);
    1.18 +	tw32(HOSTCC_RXMAX_FRAMES, DEFAULT_RXMAX_FRAMES); //1);
    1.19 +	tw32(HOSTCC_RXCOAL_TICK_INT, DEFAULT_RXCOAL_TICK_INT); //, 0);
    1.20 +	tw32(HOSTCC_RXCOAL_MAXF_INT, DEFAULT_RXCOAL_MAXF_INT); //, 1);
    1.21 +	tw32(HOSTCC_TXCOL_TICKS, DEFAULT_TXCOL_TICKS); //, LOW_TXCOL_TICKS);
    1.22 +	tw32(HOSTCC_TXMAX_FRAMES, DEFAULT_TXMAX_FRAMES); //, LOW_RXMAX_FRAMES);
    1.23 +	tw32(HOSTCC_TXCOAL_TICK_INT, DEFAULT_TXCOAL_TICK_INT); //, 0);
    1.24 +	tw32(HOSTCC_TXCOAL_MAXF_INT, DEFAULT_TXCOAL_MAXF_INT); //, 0);
    1.25  	tw32(HOSTCC_STAT_COAL_TICKS,
    1.26  	     DEFAULT_STAT_COAL_TICKS);
    1.27  
    1.28 @@ -6185,9 +6187,11 @@ static int __devinit tg3_get_invariants(
    1.29  	}
    1.30  
    1.31  	tp->rx_offset = 2;
    1.32 +
    1.33  	if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 &&
    1.34  	    (tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0)
    1.35 -		tp->rx_offset = 0;
    1.36 +                printk("WARNING: This card may not support unaligned receive pointers.\n");
    1.37 +		//tp->rx_offset = 0;
    1.38  
    1.39  	/* By default, disable wake-on-lan.  User can change this
    1.40  	 * using ETHTOOL_SWOL.
     2.1 --- a/xen-2.4.16/drivers/net/tg3.h	Wed Feb 12 17:46:52 2003 +0000
     2.2 +++ b/xen-2.4.16/drivers/net/tg3.h	Fri Feb 14 13:15:39 2003 +0000
     2.3 @@ -21,7 +21,7 @@
     2.4  #define TG3_BDINFO_NIC_ADDR		0xcUL /* 32-bit */
     2.5  #define TG3_BDINFO_SIZE			0x10UL
     2.6  
     2.7 -#define RX_COPY_THRESHOLD  		256
     2.8 +#define RX_COPY_THRESHOLD  		0 //256
     2.9  
    2.10  #define RX_STD_MAX_SIZE			1536
    2.11  #define RX_JUMBO_MAX_SIZE		0xdeadbeef /* XXX */
     3.1 --- a/xen-2.4.16/include/asm-i386/pci.h	Wed Feb 12 17:46:52 2003 +0000
     3.2 +++ b/xen-2.4.16/include/asm-i386/pci.h	Fri Feb 14 13:15:39 2003 +0000
     3.3 @@ -76,18 +76,7 @@ static inline dma_addr_t pci_map_single(
     3.4  		BUG();
     3.5  	flush_write_buffers();
     3.6  
     3.7 -        if ((unsigned long) ptr > PAGE_OFFSET)
     3.8 -	    return virt_to_bus(ptr);
     3.9 -
    3.10 -        /* If an address that is not in hypervisor VM is passed to this 
    3.11 -         * function (ie > PAGE_OFFSET) we assume that the passer knows 
    3.12 -         * what they are doing, and have passed a physical address that 
    3.13 -         * should not be converted here.  This is a little hackish, but 
    3.14 -         * is being added to allow references to domain memory in order 
    3.15 -         * to support zero-copy network code.
    3.16 -         */
    3.17 -        
    3.18 -        return (dma_addr_t) ptr;
    3.19 +	return virt_to_bus(ptr);
    3.20  }
    3.21  
    3.22  /* Unmap a single streaming mode DMA translation.  The dma_addr and size
     4.1 --- a/xen-2.4.16/net/dev.c	Wed Feb 12 17:46:52 2003 +0000
     4.2 +++ b/xen-2.4.16/net/dev.c	Fri Feb 14 13:15:39 2003 +0000
     4.3 @@ -712,28 +712,20 @@ void deliver_packet(struct sk_buff *skb,
     4.4              rx = shadow_ring->rx_ring+i;
     4.5              if ( (skb->len + ETH_HLEN) < rx->size )
     4.6                  rx->size = skb->len + ETH_HLEN;
     4.7 -                        
     4.8 -            
     4.9              
    4.10              g_pte = map_domain_mem(rx->addr);
    4.11  
    4.12              g_pfn =  frame_table + (*g_pte >> PAGE_SHIFT);
    4.13              h_pfn = skb->pf;
    4.14  
    4.15 -            //flip and/or set relevant pf_info fields.
    4.16 -            //tmp = g_pfn->next; g_pfn->next = h_pfn->next; h_pfn->next = tmp;
    4.17 -            //tmp = g_pfn->prev; g_pfn->prev = h_pfn->prev; h_pfn->prev = tmp;
    4.18 -            //tmp = g_pfn->flags; g_pfn->flags = h_pfn->flags; h_pfn->flags = tmp;
    4.19              h_pfn->tot_count = h_pfn->type_count = 1;
    4.20              g_pfn->tot_count = g_pfn->type_count = 0;
    4.21              h_pfn->flags = g_pfn->flags & (~PG_type_mask);
    4.22 -//if (h_pfn->flags & PG_domain_mask) printk("deliver packet to dom %lu\n", (h_pfn->flags & PG_domain_mask));
    4.23 +
    4.24              if (*g_pte & _PAGE_RW) h_pfn->flags |= PGT_writeable_page;
    4.25              g_pfn->flags = 0;
    4.26 +            
    4.27              //point guest pte at the new page:
    4.28 -
    4.29 -//printk("newmpfn: %lx, old mpfn: %lx,  old:(%lx) new:(%lx)\n", h_pfn - frame_table, *g_pte >> PAGE_SHIFT, machine_to_phys_mapping[h_pfn - frame_table], machine_to_phys_mapping[*g_pte >> PAGE_SHIFT]);
    4.30 -
    4.31              machine_to_phys_mapping[h_pfn - frame_table] 
    4.32                      = machine_to_phys_mapping[g_pfn - frame_table];
    4.33  
    4.34 @@ -791,7 +783,8 @@ int netif_rx(struct sk_buff *skb)
    4.35  	    get_fast_time(&skb->stamp);
    4.36  
    4.37          if ( (skb->data - skb->head) != (18 + ETH_HLEN) )
    4.38 -            BUG();
    4.39 +            printk("headroom was %lu!\n", (unsigned long)skb->data - (unsigned long)skb->head);
    4.40 +        //    BUG();
    4.41          
    4.42          skb->head = (u8 *)map_domain_mem(((skb->pf - frame_table) << PAGE_SHIFT));
    4.43  
    4.44 @@ -818,11 +811,12 @@ int netif_rx(struct sk_buff *skb)
    4.45                  
    4.46          if ( skb->dst_vif == VIF_UNKNOWN_INTERFACE )
    4.47              skb->dst_vif = __net_get_target_vif(skb->mac.raw, skb->len, skb->src_vif);
    4.48 -if (skb->dst_vif == VIF_DROP)
    4.49 -printk("netif_rx target: %d (sec: %u)\n", skb->dst_vif, skb->security);
    4.50 +//if (skb->dst_vif == VIF_DROP)
    4.51 +//printk("netif_rx target: %d (sec: %u)\n", skb->dst_vif, skb->security);
    4.52          
    4.53          if ( (vif = sys_vif_list[skb->dst_vif]) == NULL )
    4.54          {
    4.55 +//printk("No such vif! (%d).\n", skb->dst_vif);
    4.56              // the target vif does not exist.
    4.57              goto drop;
    4.58          }
    4.59 @@ -2258,7 +2252,7 @@ long do_net_update(void)
    4.60              {
    4.61                  // Local delivery: Allocate an skb off the domain free list
    4.62                  // fil it, and pass it to netif_rx as if it came off the NIC.
    4.63 -
    4.64 +//printk("LOCAL! (%d) \n", target);
    4.65                  skb = dev_alloc_skb(tx.size);
    4.66                  if (skb == NULL) 
    4.67                  {
    4.68 @@ -2269,13 +2263,16 @@ long do_net_update(void)
    4.69                  skb->src_vif = current_vif->id;
    4.70                  skb->dst_vif = target;
    4.71                  skb->protocol = protocol;
    4.72 -                if (copy_to_user(skb->data, g_data, tx.size))
    4.73 -                {
    4.74 -                    unmap_domain_mem(g_data);
    4.75 -                    continue;
    4.76 -                }
    4.77 +
    4.78 +                skb->head = (u8 *)map_domain_mem(((skb->pf - frame_table) << PAGE_SHIFT));
    4.79 +                skb->data = skb->head + 16;
    4.80 +                skb_reserve(skb,2);
    4.81 +                memcpy(skb->data, g_data, tx.size);
    4.82 +                skb->len = tx.size;
    4.83 +                unmap_domain_mem(skb->head);
    4.84 +                skb->data += ETH_HLEN; // so the assertion in netif_RX doesn't freak out.
    4.85                  
    4.86 -                (void)netif_rx(skb); // why is there a void here?  It's from the old code.
    4.87 +                (void)netif_rx(skb);
    4.88  
    4.89                  unmap_domain_mem(g_data);
    4.90              }
     5.1 --- a/xen-2.4.16/net/skbuff.c	Wed Feb 12 17:46:52 2003 +0000
     5.2 +++ b/xen-2.4.16/net/skbuff.c	Fri Feb 14 13:15:39 2003 +0000
     5.3 @@ -63,6 +63,7 @@
     5.4  
     5.5  #include <asm/uaccess.h>
     5.6  #include <asm/system.h>
     5.7 +#include <asm/io.h>
     5.8  
     5.9  #define BUG_TRAP ASSERT
    5.10  
    5.11 @@ -149,6 +150,8 @@ static __inline__ void skb_head_to_pool(
    5.12  	kmem_cache_free(skbuff_head_cache, skb);
    5.13  }
    5.14  
    5.15 +//static unsigned long skbpagesout=0, skbpagesin=0;
    5.16 +
    5.17  static inline u8 *alloc_skb_data_page(struct sk_buff *skb)
    5.18  {
    5.19          struct list_head *list_ptr;
    5.20 @@ -169,6 +172,7 @@ static inline u8 *alloc_skb_data_page(st
    5.21          spin_unlock_irqrestore(&free_list_lock, flags);
    5.22  
    5.23          skb->pf = pf;
    5.24 +//if (skbpagesout++ % 100 == 0) printk("XEN-: skb allocs: %lu\n", skbpagesout);
    5.25          return (u8 *)((pf - frame_table) << PAGE_SHIFT);
    5.26  }
    5.27  
    5.28 @@ -185,6 +189,8 @@ static inline void dealloc_skb_data_page
    5.29          free_pfns++;
    5.30  
    5.31          spin_unlock_irqrestore(&free_list_lock, flags);
    5.32 +
    5.33 +//if (skbpagesin++ % 100 == 0) printk("XEN-: skb allocs: %lu\n", skbpagesin);
    5.34  }
    5.35  
    5.36  struct sk_buff *alloc_zc_skb(unsigned int size,int gfp_mask)
    5.37 @@ -217,6 +223,11 @@ struct sk_buff *alloc_zc_skb(unsigned in
    5.38          if (data == NULL)
    5.39                  goto nodata;
    5.40  
    5.41 +        // This is so that pci_map_single does the right thing in the driver.
    5.42 +        // If you want to ever use this pointer otherwise, you need to regenerate it 
    5.43 +        // based on skb->pf.
    5.44 +        data = phys_to_virt((unsigned long)data); 
    5.45 +        
    5.46          /* XXX: does not include slab overhead */
    5.47          skb->truesize = size + sizeof(struct sk_buff);
    5.48  
     6.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/drivers/network/network.c	Wed Feb 12 17:46:52 2003 +0000
     6.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/drivers/network/network.c	Fri Feb 14 13:15:39 2003 +0000
     6.3 @@ -38,7 +38,7 @@
     6.4  #define TX_RING_ADD(_i,_j) (((_i)+(_j)) & (TX_RING_SIZE-1))
     6.5  #define RX_RING_ADD(_i,_j) (((_i)+(_j)) & (RX_RING_SIZE-1))
     6.6  
     6.7 -#define RX_BUF_SIZE 1600 /* Ethernet MTU + plenty of slack! */
     6.8 +#define RX_BUF_SIZE 2049 /* (was 1600) Ethernet MTU + plenty of slack! */
     6.9  
    6.10  static void network_rx_int(int irq, void *dev_id, struct pt_regs *ptregs);
    6.11  static void network_tx_int(int irq, void *dev_id, struct pt_regs *ptregs);
     7.1 --- a/xenolinux-2.4.16-sparse/include/linux/skbuff.h	Wed Feb 12 17:46:52 2003 +0000
     7.2 +++ b/xenolinux-2.4.16-sparse/include/linux/skbuff.h	Fri Feb 14 13:15:39 2003 +0000
     7.3 @@ -1066,8 +1066,8 @@ static inline struct sk_buff *__dev_allo
     7.4  {
     7.5  	struct sk_buff *skb;
     7.6  
     7.7 -	//skb = alloc_skb(length+16, gfp_mask);
     7.8 -        skb = alloc_zc_skb(length+16, gfp_mask);
     7.9 +	skb = alloc_skb(length+16, gfp_mask);
    7.10 +        //skb = alloc_zc_skb(length+16, gfp_mask);
    7.11  	if (skb)
    7.12  		skb_reserve(skb,16);
    7.13  	return skb;