RE: [PATCH] NAPI support for Sibyte MAC

2007-03-26 Thread Mark E Mason
Hello, 

 -Original Message-
 From: Sergei Shtylyov [mailto:[EMAIL PROTECTED] 
 Sent: Saturday, March 24, 2007 12:49 PM
 To: Mark E Mason
 Cc: [EMAIL PROTECTED]; netdev@vger.kernel.org
 Subject: Re: [PATCH] NAPI support for Sibyte MAC

[snip]
  @@ -2075,12 +2143,52 @@
   */
   
  if (isr  (M_MAC_INT_CHANNEL  S_MAC_TX_CH0)) {
  -   sbdma_tx_process(sc,(sc-sbm_txdma));
  +   sbdma_tx_process(sc,(sc-sbm_txdma), 0);
  +#ifdef CONFIG_NETPOLL_TRAP
  +  if (netpoll_trap()) {
  +  if 
 (test_and_clear_bit(__LINK_STATE_XOFF, dev-state)) 
  +  __netif_schedule(dev);
  +  }
  +#endif
  }
 
 This just doesn't make sense. That option is enabled to 
 *prevent* calls to 
 __netif_schedule() -- you can't override it that way. (Well, 
 how it works 
 currently, doesn't make much sense either since it totally 
 breaks the TX queue 
 control -- I was going to post a patch).

I'll admit - this was just copied over from the non-NAPI version we
started with ;-).

Are you saying that the #ifdef test should simply be an #ifndef here?

[I'm working on a revised patch based on feedback from Ralf and others
which removes the Kconfig option for NAPI - it'll just be on, all the
time.]

Thanks,
Mark

-
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


Re: [PATCH] NAPI support for Sibyte MAC

2007-03-24 Thread Sergei Shtylyov

Hello, you wrote:


  This patch completes the NAPI functionality for SB1250 MAC, including making
  NAPI a kernel option that can be turned on or off and adds the sbmac_poll
  routine.



Index: linux-2.6.14-cgl/drivers/net/Kconfig
===
--- linux-2.6.14-cgl.orig/drivers/net/Kconfig   2006-09-20 14:58:54.0 
-0700
+++ linux-2.6.14-cgl/drivers/net/Kconfig2006-09-20 17:04:31.0 
-0700


[...]


@@ -2075,12 +2143,52 @@
 */
 
 		if (isr  (M_MAC_INT_CHANNEL  S_MAC_TX_CH0)) {

-   sbdma_tx_process(sc,(sc-sbm_txdma));
+   sbdma_tx_process(sc,(sc-sbm_txdma), 0);
+#ifdef CONFIG_NETPOLL_TRAP
+  if (netpoll_trap()) {
+			   if (test_and_clear_bit(__LINK_STATE_XOFF, dev-state)) 
+   __netif_schedule(dev);

+  }
+#endif
}


   This just doesn't make sense. That option is enabled to *prevent* calls to 
__netif_schedule() -- you can't override it that way. (Well, how it works 
currently, doesn't make much sense either since it totally breaks the TX queue 
control -- I was going to post a patch).



+   if (isr  (M_MAC_INT_CHANNEL  S_MAC_RX_CH0)) {
+   if (netif_rx_schedule_prep(dev)) {
+   __raw_writeq(0, sc-sbm_imr);
+   __netif_rx_schedule(dev);
+   /* Depend on the exit from poll to reenable intr */
+   }
+   else {
+   /* may leave some packets behind */
+   sbdma_rx_process(sc,(sc-sbm_rxdma),
+SBMAC_MAX_RXDESCR * 2, 0);
+   }
+   }
+#else
+   /* Non NAPI */
+   for (;;) {
+ 
 		/*

-* Receives on channel 0
+* Read the ISR (this clears the bits in the real
+* register, except for counter addr)
 */
+   isr = __raw_readq(sc-sbm_isr)  ~M_MAC_COUNTER_ADDR;
+
+   if (isr == 0)
+   break;
+
+   handled = 1;
+
+   if (isr  (M_MAC_INT_CHANNEL  S_MAC_TX_CH0)) {
+   sbdma_tx_process(sc,(sc-sbm_txdma),
+SBMAC_MAX_RXDESCR * 2);
+#ifdef CONFIG_NETPOLL_TRAP
+  if (netpoll_trap()) {
+			   if (test_and_clear_bit(__LINK_STATE_XOFF, dev-state)) 
+   __netif_schedule(dev);

+  }
+#endif
+   }


   Same here.

WBR, Sergei
-
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] NAPI support for Sibyte MAC

2007-03-23 Thread mason

[ This is a re-post, but the patch still applies and works fine against
the linux-mips.org tip. We'd really like to get this in. -Mark]

  This patch completes the NAPI functionality for SB1250 MAC, including making
  NAPI a kernel option that can be turned on or off and adds the sbmac_poll
  routine.

Signed off by: Mark Mason ([EMAIL PROTECTED])
Signed off by: Dan Krejsa ([EMAIL PROTECTED])
Signed off by: Steve Yang ([EMAIL PROTECTED])

Index: linux-2.6.14-cgl/drivers/net/Kconfig
===
--- linux-2.6.14-cgl.orig/drivers/net/Kconfig   2006-09-20 14:58:54.0 
-0700
+++ linux-2.6.14-cgl/drivers/net/Kconfig2006-09-20 17:04:31.0 
-0700
@@ -2031,6 +2031,23 @@
tristate SB1250 Ethernet support
depends on SIBYTE_SB1xxx_SOC
 
+config SBMAC_NAPI
+   bool SBMAC: Use Rx Polling (NAPI) (EXPERIMENTAL)
+   depends on NET_SB1250_MAC  EXPERIMENTAL
+   help
+ NAPI is a new driver API designed to reduce CPU and interrupt load
+ when the driver is receiving lots of packets from the card. It is
+ still somewhat experimental and thus not yet enabled by default.
+
+ If your estimated Rx load is 10kpps or more, or if the card will be
+ deployed on potentially unfriendly networks (e.g. in a firewall),
+ then say Y here.
+
+ See file:Documentation/networking/NAPI_HOWTO.txt for more
+ information.
+
+ If in doubt, say y.
+
 config R8169_VLAN
bool VLAN support
depends on R8169  VLAN_8021Q
@@ -2826,3 +2843,5 @@
def_bool NETPOLL
 
 endmenu
+
+
Index: linux-2.6.14-cgl/drivers/net/sb1250-mac.c
===
--- linux-2.6.14-cgl.orig/drivers/net/sb1250-mac.c  2006-09-20 
14:59:00.0 -0700
+++ linux-2.6.14-cgl/drivers/net/sb1250-mac.c   2006-09-20 20:16:27.0 
-0700
@@ -95,19 +95,28 @@
 #endif
 
 #ifdef CONFIG_SBMAC_COALESCE
-static int int_pktcnt = 0;
-module_param(int_pktcnt, int, S_IRUGO);
-MODULE_PARM_DESC(int_pktcnt, Packet count);
-
-static int int_timeout = 0;
-module_param(int_timeout, int, S_IRUGO);
-MODULE_PARM_DESC(int_timeout, Timeout value);
+static int int_pktcnt_tx = 255;
+module_param(int_pktcnt_tx, int, S_IRUGO);
+MODULE_PARM_DESC(int_pktcnt_tx, TX packet count);
+
+static int int_timeout_tx = 255;
+module_param(int_timeout_tx, int, S_IRUGO);
+MODULE_PARM_DESC(int_timeout_tx, TX timeout value);
+
+static int int_pktcnt_rx = 64;
+module_param(int_pktcnt_rx, int, S_IRUGO);
+MODULE_PARM_DESC(int_pktcnt_rx, RX packet count);
+
+static int int_timeout_rx = 64;
+module_param(int_timeout_rx, int, S_IRUGO);
+MODULE_PARM_DESC(int_timeout_rx, RX timeout value);
 #endif
 
 #include asm/sibyte/sb1250.h
 #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
 #include asm/sibyte/bcm1480_regs.h
 #include asm/sibyte/bcm1480_int.h
+#define R_MAC_DMA_OODPKTLOST_RXR_MAC_DMA_OODPKTLOST
 #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
 #include asm/sibyte/sb1250_regs.h
 #include asm/sibyte/sb1250_int.h
@@ -155,8 +164,8 @@
 
 #define NUMCACHEBLKS(x) (((x)+SMP_CACHE_BYTES-1)/SMP_CACHE_BYTES)
 
-#define SBMAC_MAX_TXDESCR  32
-#define SBMAC_MAX_RXDESCR  32
+#define SBMAC_MAX_TXDESCR  256
+#define SBMAC_MAX_RXDESCR  256
 
 #define ETHER_ALIGN2
 #define ETHER_ADDR_LEN 6
@@ -185,10 +194,10 @@
 * associated with it.
 */
 
-   struct sbmac_softc *sbdma_eth;  /* back pointer to associated 
MAC */
-   int  sbdma_channel; /* channel number */
+   struct sbmac_softc *sbdma_eth;  /* back pointer to associated MAC */
+   int  sbdma_channel; /* channel number */
int  sbdma_txdir;   /* direction (1=transmit) */
-   int  sbdma_maxdescr;/* total # of descriptors in 
ring */
+   int  sbdma_maxdescr;/* total # of descriptors in ring */
 #ifdef CONFIG_SBMAC_COALESCE
int  sbdma_int_pktcnt;  /* # descriptors rx/tx before 
interrupt*/
int  sbdma_int_timeout; /* # usec rx/tx interrupt */
@@ -197,13 +206,16 @@
volatile void __iomem *sbdma_config0;   /* DMA config register 0 */
volatile void __iomem *sbdma_config1;   /* DMA config register 1 */
volatile void __iomem *sbdma_dscrbase;  /* Descriptor base address */
-   volatile void __iomem *sbdma_dscrcnt; /* Descriptor count register 
*/
+   volatile void __iomem *sbdma_dscrcnt;   /* Descriptor count register */
volatile void __iomem *sbdma_curdscr;   /* current descriptor address */
+   volatile void __iomem *sbdma_oodpktlost;/* pkt drop (rx only) */
+
 
/*
 * This stuff is for maintenance of the ring
 */
 
+   sbdmadscr_t *sbdma_dscrtable_unaligned;
sbdmadscr_t *sbdma_dscrtable;   /* base of