All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] arch/ppc/8xx_io/enet.c
@ 2002-10-23  7:51 Joakim Tjernlund
  2002-10-23 15:32 ` Ricardo Scop
  0 siblings, 1 reply; 18+ messages in thread
From: Joakim Tjernlund @ 2002-10-23  7:51 UTC (permalink / raw)
  To: linuxppc-embedded


On Monday 21 October 2002 15:13, Joakim Tjernlund wrote:
> Hi
>
> Here is a patch to drop the expensive memcpy of received ethernet frames in
> interrupt context. I have not done any bench marking, but mounting a NFS
> rootfs feels faster.
>
> I am using a heavily modified enet.c in my system, but I think I got the
> patch correct.
>
> Also fixed a bug in set_multicast_list(), move the dmi list forward when
> walking it(dmi = dmi->next;)
>
> Comments? Anyone care to do some benchmarking?

No comments so far, no one interested in this?

A question, why do enet.c pass bad frames to netif_rx? Only late collisions
are disregarded, the rest is passed on.

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 18+ messages in thread
* [PATCH] arch/ppc/8xx_io/enet.c
@ 2002-10-21 13:13 Joakim Tjernlund
  0 siblings, 0 replies; 18+ messages in thread
From: Joakim Tjernlund @ 2002-10-21 13:13 UTC (permalink / raw)
  To: linuxppc-embedded


Hi

Here is a patch to drop the expensive memcpy of received ethernet frames in
interrupt context. I have not done any bench marking, but mounting a NFS rootfs feels faster.

I am using a heavily modified enet.c in my system, but I think I got the patch correct.

Also fixed a bug in set_multicast_list(), move the dmi list forward when walking it(dmi = dmi->next;)

Comments? Anyone care to do some benchmarking?

        Jocke

 --- arch/ppc/8xx_io/enet.c.org	Mon Oct 21 14:35:59 2002
+++ arch/ppc/8xx_io/enet.c	Mon Oct 21 15:06:04 2002
@@ -96,18 +96,17 @@
  * We don't need to allocate pages for the transmitter.  We just use
  * the skbuffer directly.
  */
+#define CPM_ENET_RX_FRSIZE	1600   /* MUST be a multiple of cache line! */
+#if CPM_ENET_RX_FRSIZE % L1_CACHE_LINE_SIZE != 0
+    #error CPM_ENET_RX_FRSIZE must be a multiple of L1 cache size
+#endif
+
 #ifdef CONFIG_ENET_BIG_BUFFERS
-#define CPM_ENET_RX_PAGES	32
-#define CPM_ENET_RX_FRSIZE	2048
-#define CPM_ENET_RX_FRPPG	(PAGE_SIZE / CPM_ENET_RX_FRSIZE)
-#define RX_RING_SIZE		(CPM_ENET_RX_FRPPG * CPM_ENET_RX_PAGES)
+#define RX_RING_SIZE		64
 #define TX_RING_SIZE		64	/* Must be power of two */
 #define TX_RING_MOD_MASK	63	/*   for this to work */
 #else
-#define CPM_ENET_RX_PAGES	4
-#define CPM_ENET_RX_FRSIZE	2048
-#define CPM_ENET_RX_FRPPG	(PAGE_SIZE / CPM_ENET_RX_FRSIZE)
-#define RX_RING_SIZE		(CPM_ENET_RX_FRPPG * CPM_ENET_RX_PAGES)
+#define RX_RING_SIZE		8
 #define TX_RING_SIZE		8	/* Must be power of two */
 #define TX_RING_MOD_MASK	7	/*   for this to work */
 #endif
@@ -143,7 +142,7 @@
 	/* Virtual addresses for the receive buffers because we can't
 	 * do a __va() on them anymore.
 	 */
-	unsigned char *rx_vaddr[RX_RING_SIZE];
+	void    *rx_vaddr[RX_RING_SIZE];
 	struct	net_device_stats stats;
 	uint	tx_full;
 	spinlock_t lock;
@@ -449,6 +448,7 @@
 	struct	scc_enet_private *cep;
 	volatile cbd_t	*bdp;
 	struct	sk_buff *skb;
+	struct	sk_buff *skb_tmp;
 	ushort	pkt_len;

 	cep = (struct scc_enet_private *)dev->priv;
@@ -497,25 +497,26 @@
 		pkt_len = bdp->cbd_datlen;
 		cep->stats.rx_bytes += pkt_len;

-		/* This does 16 byte alignment, much more than we need.
+		/* This does 16 byte alignment, exactly what we need.
 		 * The packet length includes FCS, but we don't want to
 		 * include that when passing upstream as it messes up
 		 * bridging applications.
 		 */
-		skb = dev_alloc_skb(pkt_len-4);
-
-		if (skb == NULL) {
+		skb_tmp = dev_alloc_skb(CPM_ENET_RX_FRSIZE);
+		if (skb_tmp == NULL) {
 			printk("%s: Memory squeeze, dropping packet.\n", dev->name);
 			cep->stats.rx_dropped++;
-		}
-		else {
+		} else {
+			skb = cep->rx_vaddr[bdp - cep->rx_bd_base];
 			skb->dev = dev;
 			skb_put(skb,pkt_len-4);	/* Make room */
-			eth_copy_and_sum(skb,
-				cep->rx_vaddr[bdp - cep->rx_bd_base],
-				pkt_len-4, 0);
 			skb->protocol=eth_type_trans(skb,dev);
 			netif_rx(skb);
+
+			invalidate_dcache_range((unsigned long) skb_tmp->data,
+						(unsigned long) skb_tmp->data + CPM_ENET_RX_FRSIZE);
+			bdp->cbd_bufaddr = __pa(skb_tmp->data);
+			cep->rx_vaddr[bdp - cep->rx_bd_base] = skb_tmp;
 		}
 	}

@@ -631,6 +632,7 @@
 				/* this delay is necessary here -- Cort */
 				udelay(10);
 				while (cpmp->cp_cpcr & CPM_CR_FLG);
+				dmi = dmi->next;
 			}
 		}
 	}
@@ -647,8 +649,7 @@
 	struct net_device *dev;
 	struct scc_enet_private *cep;
 	int i, j, k;
-	unsigned char	*eap, *ba;
-	dma_addr_t	mem_addr;
+	unsigned char	*eap;
 	bd_t		*bd;
 	volatile	cbd_t		*bdp;
 	volatile	cpm8xx_t	*cp;
@@ -839,22 +840,15 @@

 	bdp = cep->rx_bd_base;
 	k = 0;
-	for (i=0; i<CPM_ENET_RX_PAGES; i++) {
-
-		/* Allocate a page.
-		*/
-		ba = (unsigned char *)consistent_alloc(GFP_KERNEL, PAGE_SIZE, &mem_addr);
-
-		/* Initialize the BD for every fragment in the page.
-		*/
-		for (j=0; j<CPM_ENET_RX_FRPPG; j++) {
-			bdp->cbd_sc = BD_ENET_RX_EMPTY | BD_ENET_RX_INTR;
-			bdp->cbd_bufaddr = mem_addr;
-			cep->rx_vaddr[k++] = ba;
-			mem_addr += CPM_ENET_RX_FRSIZE;
-			ba += CPM_ENET_RX_FRSIZE;
-			bdp++;
-		}
+	/* Initialize the BDs. */
+	for (j=0; j < RX_RING_SIZE; j++) {
+		struct	sk_buff * skb = dev_alloc_skb(CPM_ENET_RX_FRSIZE);
+		bdp->cbd_sc = BD_ENET_RX_EMPTY | BD_ENET_RX_INTR;
+		bdp->cbd_bufaddr = __pa(skb->data);
+		invalidate_dcache_range((unsigned long) skb->data,
+					(unsigned long) skb->data + CPM_ENET_RX_FRSIZE);
+		cep->rx_vaddr[k++] = skb;
+		bdp++;
 	}

 	/* Set the last buffer to wrap.

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2002-11-04 10:25 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-23  7:51 [PATCH] arch/ppc/8xx_io/enet.c Joakim Tjernlund
2002-10-23 15:32 ` Ricardo Scop
2002-10-23 15:44   ` Ricardo Scop
2002-10-25 16:02     ` dc* (Data Cache) instructions in mem*() and *_page() functions not used on 8xx Joakim Tjernlund
2002-10-27 23:23       ` Joakim Tjernlund
2002-10-29 15:27         ` Dan Malek
2002-10-29 16:02           ` Joakim Tjernlund
2002-10-29 16:23             ` Dan Malek
2002-10-29 18:07               ` Joakim Tjernlund
2002-11-01 11:14                 ` Joakim Tjernlund
2002-11-01 17:33                   ` Dan Malek
2002-11-01 19:27                     ` Joakim Tjernlund
2002-11-04  2:09                       ` Dan Malek
2002-11-04 10:25                         ` Joakim Tjernlund
2002-10-24  7:14   ` [PATCH] arch/ppc/8xx_io/enet.c Joakim Tjernlund
2002-10-24 10:12   ` Steven Scholz
2002-10-24 10:14     ` Joakim Tjernlund
  -- strict thread matches above, loose matches on Subject: below --
2002-10-21 13:13 Joakim Tjernlund

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.