]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
fm10k: set netdev features in one location
authorJacob Keller <jacob.e.keller@intel.com>
Fri, 16 Oct 2015 17:56:56 +0000 (10:56 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Sun, 6 Dec 2015 07:55:13 +0000 (23:55 -0800)
Don't change netdev hw_features later in fm10k_probe, instead set all
values inside fm10k_alloc_netdev. To do so, we need to know the MAC type
(whether it is PF or VF) in order to determine what to do. This helps
ensure that all logic regarding features is co-located.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Bruce Allan <bruce.w.allan@intel.com>
Tested-by: Krishneil Singh <krishneil.k.singh@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/fm10k/fm10k.h
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
drivers/net/ethernet/intel/fm10k/fm10k_pci.c

index 48809e5d3f7975fcb2d825cf2be35f1a114b5491..b178905fa43e794aaf933afe4b7797a7586d9538 100644 (file)
@@ -484,7 +484,7 @@ void fm10k_netpoll(struct net_device *netdev);
 #endif
 
 /* Netdev */
-struct net_device *fm10k_alloc_netdev(void);
+struct net_device *fm10k_alloc_netdev(const struct fm10k_info *info);
 int fm10k_setup_rx_resources(struct fm10k_ring *);
 int fm10k_setup_tx_resources(struct fm10k_ring *);
 void fm10k_free_rx_resources(struct fm10k_ring *);
index 7781e80896a60a59e12eec15582cc3743447e1dd..79f6b7dd23621ec5fb4295e7c53ea0592c934d61 100644 (file)
@@ -1388,8 +1388,9 @@ static const struct net_device_ops fm10k_netdev_ops = {
 
 #define DEFAULT_DEBUG_LEVEL_SHIFT 3
 
-struct net_device *fm10k_alloc_netdev(void)
+struct net_device *fm10k_alloc_netdev(const struct fm10k_info *info)
 {
+       netdev_features_t hw_features;
        struct fm10k_intfc *interface;
        struct net_device *dev;
 
@@ -1412,27 +1413,31 @@ struct net_device *fm10k_alloc_netdev(void)
                         NETIF_F_TSO |
                         NETIF_F_TSO6 |
                         NETIF_F_TSO_ECN |
-                        NETIF_F_GSO_UDP_TUNNEL |
                         NETIF_F_RXHASH |
                         NETIF_F_RXCSUM;
 
+       /* Only the PF can support VXLAN and NVGRE tunnel offloads */
+       if (info->mac == fm10k_mac_pf) {
+               dev->hw_enc_features = NETIF_F_IP_CSUM |
+                                      NETIF_F_TSO |
+                                      NETIF_F_TSO6 |
+                                      NETIF_F_TSO_ECN |
+                                      NETIF_F_GSO_UDP_TUNNEL |
+                                      NETIF_F_IPV6_CSUM |
+                                      NETIF_F_SG;
+
+               dev->features |= NETIF_F_GSO_UDP_TUNNEL;
+       }
+
        /* all features defined to this point should be changeable */
-       dev->hw_features |= dev->features;
+       hw_features = dev->features;
 
        /* allow user to enable L2 forwarding acceleration */
-       dev->hw_features |= NETIF_F_HW_L2FW_DOFFLOAD;
+       hw_features |= NETIF_F_HW_L2FW_DOFFLOAD;
 
        /* configure VLAN features */
        dev->vlan_features |= dev->features;
 
-       /* configure tunnel offloads */
-       dev->hw_enc_features |= NETIF_F_IP_CSUM |
-                               NETIF_F_TSO |
-                               NETIF_F_TSO6 |
-                               NETIF_F_TSO_ECN |
-                               NETIF_F_GSO_UDP_TUNNEL |
-                               NETIF_F_IPV6_CSUM;
-
        /* we want to leave these both on as we cannot disable VLAN tag
         * insertion or stripping on the hardware since it is contained
         * in the FTAG and not in the frame itself.
@@ -1443,5 +1448,7 @@ struct net_device *fm10k_alloc_netdev(void)
 
        dev->priv_flags |= IFF_UNICAST_FLT;
 
+       dev->hw_features |= hw_features;
+
        return dev;
 }
index 5fbffbaefe323a2fe41abb2bb5d3b8b7bbd377b0..1af4b222d00385cd6de251e7d81656612789b9ab 100644 (file)
@@ -1722,13 +1722,6 @@ static int fm10k_sw_init(struct fm10k_intfc *interface,
                                             pci_resource_len(pdev, 4));
        hw->sw_addr = interface->sw_addr;
 
-       /* Only the PF can support VXLAN and NVGRE offloads */
-       if (hw->mac.type != fm10k_mac_pf) {
-               netdev->hw_enc_features = 0;
-               netdev->features &= ~NETIF_F_GSO_UDP_TUNNEL;
-               netdev->hw_features &= ~NETIF_F_GSO_UDP_TUNNEL;
-       }
-
        /* initialize DCBNL interface */
        fm10k_dcbnl_set_ops(netdev);
 
@@ -1894,7 +1887,7 @@ static int fm10k_probe(struct pci_dev *pdev,
        pci_set_master(pdev);
        pci_save_state(pdev);
 
-       netdev = fm10k_alloc_netdev();
+       netdev = fm10k_alloc_netdev(fm10k_info_tbl[ent->driver_data]);
        if (!netdev) {
                err = -ENOMEM;
                goto err_alloc_netdev;