Re: [PATCH 1/1] myri10ge: use physical pages for skb allocation

2006-11-15 Thread Brice Goglin
Hi Jeff,

It looks like you didn't apply this patch to #upstream for 2.6.20 so far. We 
would really like to get ith in 2.6.20 (we already missed 2.6.19 by a couple 
days :)). But, I guess we need some testing in -mm first, so...

thanks,
Brice





Brice Goglin wrote:
 Physical pages are used instead of 16kB contiguous buffers for the
 skb frags. And we also put as much fragments as possible in any page
 so that we do not have to allocate a page for every fragments.

 Signed-off-by: Brice Goglin [EMAIL PROTECTED]
 Signed-off-by: Andrew J. Gallatin [EMAIL PROTECTED]
 ---
  drivers/net/myri10ge/myri10ge.c |  499 
 
  1 file changed, 254 insertions(+), 245 deletions(-)
   

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] myri10ge: use physical pages for skb allocation

2006-10-25 Thread Brice Goglin
Physical pages are used instead of 16kB contiguous buffers for the
skb frags. And we also put as much fragments as possible in any page
so that we do not have to allocate a page for every fragments.

Signed-off-by: Brice Goglin [EMAIL PROTECTED]
Signed-off-by: Andrew J. Gallatin [EMAIL PROTECTED]
---
 drivers/net/myri10ge/myri10ge.c |  499 
 1 file changed, 254 insertions(+), 245 deletions(-)

Index: linux-rc/drivers/net/myri10ge/myri10ge.c
===
--- linux-rc.orig/drivers/net/myri10ge/myri10ge.c   2006-10-25 
14:14:59.0 +0200
+++ linux-rc/drivers/net/myri10ge/myri10ge.c2006-10-25 14:15:18.0 
+0200
@@ -61,6 +61,8 @@
 #include linux/moduleparam.h
 #include linux/io.h
 #include net/checksum.h
+#include net/ip.h
+#include net/tcp.h
 #include asm/byteorder.h
 #include asm/io.h
 #include asm/processor.h
@@ -71,7 +73,7 @@
 #include myri10ge_mcp.h
 #include myri10ge_mcp_gen_header.h
 
-#define MYRI10GE_VERSION_STR 1.0.0
+#define MYRI10GE_VERSION_STR 1.1.0
 
 MODULE_DESCRIPTION(Myricom 10G driver (10GbE));
 MODULE_AUTHOR(Maintainer: [EMAIL PROTECTED]);
@@ -91,9 +93,13 @@
 
 #define MYRI10GE_NO_CONFIRM_DATA 0x
 #define MYRI10GE_NO_RESPONSE_RESULT 0x
+#define MYRI10GE_ALLOC_ORDER 0
+#define MYRI10GE_ALLOC_SIZE ((1  MYRI10GE_ALLOC_ORDER) * PAGE_SIZE)
+#define MYRI10GE_MAX_FRAGS_PER_FRAME 
(MYRI10GE_MAX_ETHER_MTU/MYRI10GE_ALLOC_SIZE + 1)
 
 struct myri10ge_rx_buffer_state {
-   struct sk_buff *skb;
+   struct page *page;
+   int page_offset;
 DECLARE_PCI_UNMAP_ADDR(bus)
 DECLARE_PCI_UNMAP_LEN(len)
 };
@@ -116,9 +122,14 @@
u8 __iomem *wc_fifo;/* w/c rx dma addr fifo address */
struct mcp_kreq_ether_recv *shadow; /* host shadow of recv ring */
struct myri10ge_rx_buffer_state *info;
+   struct page *page;
+   dma_addr_t bus;
+   int page_offset;
int cnt;
+   int fill_cnt;
int alloc_fail;
int mask;   /* number of rx slots -1 */
+   int watchdog_needed;
 };
 
 struct myri10ge_tx_buf {
@@ -150,6 +161,7 @@
struct myri10ge_rx_buf rx_big;
struct myri10ge_rx_done rx_done;
int small_bytes;
+   int big_bytes;
struct net_device *dev;
struct net_device_stats stats;
u8 __iomem *sram;
@@ -238,11 +250,6 @@
 MODULE_PARM_DESC(myri10ge_force_firmware,
 Force firmware to assume aligned completions\n);
 
-static int myri10ge_skb_cross_4k = 0;
-module_param(myri10ge_skb_cross_4k, int, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(myri10ge_skb_cross_4k,
-Can a small skb cross a 4KB boundary?\n);
-
 static int myri10ge_initial_mtu = MYRI10GE_MAX_ETHER_MTU - ETH_HLEN;
 module_param(myri10ge_initial_mtu, int, S_IRUGO);
 MODULE_PARM_DESC(myri10ge_initial_mtu, Initial MTU\n);
@@ -266,6 +273,10 @@
 module_param(myri10ge_debug, int, 0);
 MODULE_PARM_DESC(myri10ge_debug, Debug level (0=none,...,16=all));
 
+static int myri10ge_fill_thresh = 256;
+module_param(myri10ge_fill_thresh, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(myri10ge_fill_thresh, Number of empty rx slots allowed\n);
+
 #define MYRI10GE_FW_OFFSET 1024*1024
 #define MYRI10GE_HIGHPART_TO_U32(X) \
 (sizeof (X) == 8) ? ((u32)((u64)(X)  32)) : (0)
@@ -797,194 +808,179 @@
mb();
 }
 
-/*
- * Set of routines to get a new receive buffer.  Any buffer which
- * crosses a 4KB boundary must start on a 4KB boundary due to PCIe
- * wdma restrictions. We also try to align any smaller allocation to
- * at least a 16 byte boundary for efficiency.  We assume the linux
- * memory allocator works by powers of 2, and will not return memory
- * smaller than 2KB which crosses a 4KB boundary.  If it does, we fall
- * back to allocating 2x as much space as required.
- *
- * We intend to replace large (4KB) skb allocations by using
- * pages directly and building a fraglist in the near future.
- */
-
-static inline struct sk_buff *myri10ge_alloc_big(struct net_device *dev,
-int bytes)
-{
-   struct sk_buff *skb;
-   unsigned long data, roundup;
-
-   skb = netdev_alloc_skb(dev, bytes + 4096 + MXGEFW_PAD);
-   if (skb == NULL)
-   return NULL;
-
-   /* Correct skb-truesize so that socket buffer
-* accounting is not confused the rounding we must
-* do to satisfy alignment constraints.
-*/
-   skb-truesize -= 4096;
-
-   data = (unsigned long)(skb-data);
-   roundup = (-data)  (4095);
-   skb_reserve(skb, roundup);
-   return skb;
-}
-
-/* Allocate 2x as much space as required and use whichever portion
- * does not cross a 4KB boundary */
-static inline struct sk_buff *myri10ge_alloc_small_safe(struct net_device *dev,
-   unsigned int bytes)
+static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, u16