cxgb4: implement the ETHTOOL_GRXFH command
authorDimitris Michailidis <dm@chelsio.com>
Sun, 11 Jul 2010 12:01:18 +0000 (12:01 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 12 Jul 2010 00:07:46 +0000 (17:07 -0700)
Signed-off-by: Dimitris Michailidis <dm@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/cxgb4/cxgb4.h
drivers/net/cxgb4/cxgb4_main.c
drivers/net/cxgb4/t4_hw.c

index a614eb5d85d5933beff6cebd9d20c5e17b61b3b3..4769c1c58e8586c1f431e203277ca785dbaec416 100644 (file)
@@ -294,6 +294,7 @@ struct port_info {
        u8     rx_offload;            /* CSO, etc */
        u8     nqsets;                /* # of qsets */
        u8     first_qset;            /* index of first qset */
+       u8     rss_mode;
        struct link_config link_cfg;
        u16   *rss;
 };
index 61d43130eff21e5a43eed0267ea6514a4b3ea315..110843c5fde25884d91fc20943eb23bf88636a0a 100644 (file)
@@ -1851,9 +1851,61 @@ static int set_rss_table(struct net_device *dev,
 static int get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
                     void *rules)
 {
+       const struct port_info *pi = netdev_priv(dev);
+
        switch (info->cmd) {
+       case ETHTOOL_GRXFH: {
+               unsigned int v = pi->rss_mode;
+
+               info->data = 0;
+               switch (info->flow_type) {
+               case TCP_V4_FLOW:
+                       if (v & FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN)
+                               info->data = RXH_IP_SRC | RXH_IP_DST |
+                                            RXH_L4_B_0_1 | RXH_L4_B_2_3;
+                       else if (v & FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN)
+                               info->data = RXH_IP_SRC | RXH_IP_DST;
+                       break;
+               case UDP_V4_FLOW:
+                       if ((v & FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN) &&
+                           (v & FW_RSS_VI_CONFIG_CMD_UDPEN))
+                               info->data = RXH_IP_SRC | RXH_IP_DST |
+                                            RXH_L4_B_0_1 | RXH_L4_B_2_3;
+                       else if (v & FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN)
+                               info->data = RXH_IP_SRC | RXH_IP_DST;
+                       break;
+               case SCTP_V4_FLOW:
+               case AH_ESP_V4_FLOW:
+               case IPV4_FLOW:
+                       if (v & FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN)
+                               info->data = RXH_IP_SRC | RXH_IP_DST;
+                       break;
+               case TCP_V6_FLOW:
+                       if (v & FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN)
+                               info->data = RXH_IP_SRC | RXH_IP_DST |
+                                            RXH_L4_B_0_1 | RXH_L4_B_2_3;
+                       else if (v & FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN)
+                               info->data = RXH_IP_SRC | RXH_IP_DST;
+                       break;
+               case UDP_V6_FLOW:
+                       if ((v & FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN) &&
+                           (v & FW_RSS_VI_CONFIG_CMD_UDPEN))
+                               info->data = RXH_IP_SRC | RXH_IP_DST |
+                                            RXH_L4_B_0_1 | RXH_L4_B_2_3;
+                       else if (v & FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN)
+                               info->data = RXH_IP_SRC | RXH_IP_DST;
+                       break;
+               case SCTP_V6_FLOW:
+               case AH_ESP_V6_FLOW:
+               case IPV6_FLOW:
+                       if (v & FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN)
+                               info->data = RXH_IP_SRC | RXH_IP_DST;
+                       break;
+               }
+               return 0;
+       }
        case ETHTOOL_GRXRINGS:
-               info->data = netdev2pinfo(dev)->nqsets;
+               info->data = pi->nqsets;
                return 0;
        }
        return -EOPNOTSUPP;
index 3e63d1487f5fc914903bb756a75642c382f69f04..ab46797623b6ad1afdba4b81db61f0dc75d95f9d 100644 (file)
@@ -3133,8 +3133,10 @@ int __devinit t4_port_init(struct adapter *adap, int mbox, int pf, int vf)
        u8 addr[6];
        int ret, i, j = 0;
        struct fw_port_cmd c;
+       struct fw_rss_vi_config_cmd rvc;
 
        memset(&c, 0, sizeof(c));
+       memset(&rvc, 0, sizeof(rvc));
 
        for_each_port(adap, i) {
                unsigned int rss_size;
@@ -3171,6 +3173,15 @@ int __devinit t4_port_init(struct adapter *adap, int mbox, int pf, int vf)
                p->port_type = FW_PORT_CMD_PTYPE_GET(ret);
                p->mod_type = FW_PORT_MOD_TYPE_NA;
 
+               rvc.op_to_viid = htonl(FW_CMD_OP(FW_RSS_VI_CONFIG_CMD) |
+                                      FW_CMD_REQUEST | FW_CMD_READ |
+                                      FW_RSS_VI_CONFIG_CMD_VIID(p->viid));
+               rvc.retval_len16 = htonl(FW_LEN16(rvc));
+               ret = t4_wr_mbox(adap, mbox, &rvc, sizeof(rvc), &rvc);
+               if (ret)
+                       return ret;
+               p->rss_mode = ntohl(rvc.u.basicvirtual.defaultq_to_udpen);
+
                init_link_config(&p->link_cfg, ntohs(c.u.info.pcap));
                j++;
        }