rss: Add RSS kernel option; Add IFCAP_RSS iface capability
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 13 Mar 2009 12:46:37 +0000 (20:46 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 14 Mar 2009 02:59:22 +0000 (10:59 +0800)
Convert jme(4) to use the new IFCAP_RSS.

sbin/ifconfig/ifconfig.8
sbin/ifconfig/ifconfig.c
sys/conf/options
sys/config/LINT
sys/dev/netif/jme/Makefile
sys/dev/netif/jme/if_jme.c
sys/dev/netif/jme/if_jmevar.h
sys/net/if.h

index 07bad75..59399c9 100644 (file)
@@ -313,6 +313,12 @@ operating modes.
 .It Cm name Ar name
 Set the interface name to
 .Ar name .
+.It Cm rss
+If the driver supports receive side scaling,
+enable receive side scaling on the interface.
+.It Fl rss
+If the driver supports receive side scaling,
+disable receive side scaling on the interface.
 .It Cm rxcsum , txcsum
 If the driver supports user-configurable checksum offloading,
 enable receive (or transmit) checksum offloading on the interface.
index fba84d7..6b5d4d2 100644 (file)
@@ -845,7 +845,7 @@ rt_xaddrs(caddr_t cp, caddr_t cplim, struct rt_addrinfo *rtinfo)
 "\20MULTICAST\21POLLING\22PPROMISC\23MONITOR\24STATICARP\25NEEDSGIANT"
 
 #define        IFCAPBITS \
-"\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING"
+"\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7RSS"
 
 /*
  * Print the status of the interface.  If an address family was
@@ -1084,6 +1084,8 @@ static struct cmd basic_cmds[] = {
        DEF_CMD("-txcsum",      -IFCAP_TXCSUM,  setifcap),
        DEF_CMD("netcons",      IFCAP_NETCONS,  setifcap),
        DEF_CMD("-netcons",     -IFCAP_NETCONS, setifcap),
+       DEF_CMD("rss",          IFCAP_RSS,      setifcap),
+       DEF_CMD("-rss",         -IFCAP_RSS,     setifcap),
        DEF_CMD("normal",       -IFF_LINK0,     setifflags),
        DEF_CMD("compress",     IFF_LINK0,      setifflags),
        DEF_CMD("noicmp",       IFF_LINK1,      setifflags),
index 85a0101..5c82a06 100644 (file)
@@ -653,3 +653,6 @@ SYSLINK                     opt_syslink.h
 
 # serializer profiling support
 PROFILE_SERIALIZER     opt_serializer.h
+
+# Receive Side Scaling
+RSS                    opt_rss.h
index 84103af..07f3318 100644 (file)
@@ -2804,3 +2804,6 @@ options           SCTP_MAP_LOGGING
 
 # Serializer profiling
 options                PROFILE_SERIALIZER
+
+# Receive Side Scaling
+options                RSS
index 881e024..fe52282 100644 (file)
@@ -3,7 +3,7 @@
 KMOD=  if_jme
 SRCS=  if_jme.c
 SRCS+= miibus_if.h device_if.h bus_if.h pci_if.h
-SRCS+= opt_polling.h opt_jme.h
+SRCS+= opt_polling.h opt_jme.h opt_rss.h
 KMODDEPS= miibus
 
 .ifndef BUILDING_WITH_KERNEL
@@ -14,6 +14,9 @@ opt_polling.h:
 opt_jme.h:
        touch ${.OBJDIR}/${.TARGET}
 
+opt_rss.h:
+       touch ${.OBJDIR}/${.TARGET}
+
 .endif
 
 .include <bsd.kmod.mk>
index 6cbbad4..e51d288 100644 (file)
@@ -29,6 +29,7 @@
  */
 
 #include "opt_polling.h"
+#include "opt_rss.h"
 #include "opt_jme.h"
 
 #include <sys/param.h>
@@ -615,6 +616,7 @@ jme_attach(device_t dev)
        if (sc->jme_tx_desc_cnt > JME_NDESC_MAX)
                sc->jme_tx_desc_cnt = JME_NDESC_MAX;
 
+#ifdef RSS
        sc->jme_rx_ring_cnt = jme_rx_ring_count;
        if (sc->jme_rx_ring_cnt <= 0)
                sc->jme_rx_ring_cnt = JME_NRXRING_1;
@@ -625,11 +627,9 @@ jme_attach(device_t dev)
                sc->jme_rx_ring_cnt = JME_NRXRING_4;
        else if (sc->jme_rx_ring_cnt >= JME_NRXRING_2)
                sc->jme_rx_ring_cnt = JME_NRXRING_2;
-
-       if (sc->jme_rx_ring_cnt > JME_NRXRING_MIN) {
-               sc->jme_caps |= JME_CAP_RSS;
-               sc->jme_flags |= JME_FLAG_RSS;
-       }
+#else
+       sc->jme_rx_ring_cnt = JME_NRXRING_MIN;
+#endif
        sc->jme_rx_ring_inuse = sc->jme_rx_ring_cnt;
 
        sc->jme_dev = dev;
@@ -824,6 +824,8 @@ jme_attach(device_t dev)
        ifp->if_capabilities = IFCAP_HWCSUM |
                               IFCAP_VLAN_MTU |
                               IFCAP_VLAN_HWTAGGING;
+       if (sc->jme_rx_ring_cnt > JME_NRXRING_MIN)
+               ifp->if_capabilities |= IFCAP_RSS;
        ifp->if_hwassist = JME_CSUM_FEATURES;
        ifp->if_capenable = ifp->if_capabilities;
 
@@ -1747,6 +1749,12 @@ jme_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr)
                        ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;
                        jme_set_vlan(sc);
                }
+#ifdef RSS
+               if (mask & IFCAP_RSS) {
+                       ifp->if_capenable ^= IFCAP_RSS;
+                       jme_init(sc);
+               }
+#endif
                break;
 
        default:
@@ -2250,7 +2258,7 @@ jme_init(void *xsc)
        if (sc->jme_lowaddr != BUS_SPACE_MAXADDR_32BIT)
                sc->jme_txd_spare += 1;
 
-       if (sc->jme_flags & JME_FLAG_RSS)
+       if (ifp->if_capenable & IFCAP_RSS)
                jme_enable_rss(sc);
        else
                jme_disable_rss(sc);
index 7f36c64..1c52d7a 100644 (file)
@@ -215,7 +215,6 @@ struct jme_softc {
 #define        JME_CAP_PMCAP           0x0004
 #define        JME_CAP_FASTETH         0x0008
 #define        JME_CAP_JUMBO           0x0010
-#define JME_CAP_RSS            0x0020
 
        uint32_t                jme_workaround;
 #define JME_WA_EXTFIFO         0x0001
@@ -226,7 +225,6 @@ struct jme_softc {
 #define        JME_FLAG_MSIX           0x0002
 #define        JME_FLAG_DETACH         0x0004
 #define        JME_FLAG_LINK           0x0008
-#define JME_FLAG_RSS           0x0010
 
        struct callout          jme_tick_ch;
        struct jme_chain_data   jme_cdata;
index 8da88d6..4f2af95 100644 (file)
@@ -158,6 +158,7 @@ struct if_data {
 #define IFCAP_VLAN_MTU         0x0008  /* VLAN-compatible MTU */
 #define IFCAP_VLAN_HWTAGGING   0x0010  /* hardware VLAN tag support */
 #define IFCAP_JUMBO_MTU                0x0020  /* 9000 byte MTU support */
+#define IFCAP_RSS              0x0040  /* Receive Side Scaling for IPv4 */
 
 #define IFCAP_HWCSUM           (IFCAP_RXCSUM | IFCAP_TXCSUM)