fix typos using codespell utility
[dpdk.git] / lib / librte_eal / linuxapp / kni / ethtool / igb / igb_main.c
index a802a02..99338c5 100644 (file)
@@ -17,7 +17,7 @@
   51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 
   The full GNU General Public License is included in this distribution in
-  the file called "COPYING".
+  the file called "LICENSE.GPL".
 
   Contact Information:
   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
@@ -76,7 +76,7 @@ static const char igb_driver_string[] =
 static const char igb_copyright[] =
                                "Copyright (c) 2007-2013 Intel Corporation.";
 
-static DEFINE_PCI_DEVICE_TABLE(igb_pci_tbl) = {
+const struct pci_device_id igb_pci_tbl[] = {
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_I354_BACKPLANE_1GBPS) },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_I354_SGMII) },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_I354_BACKPLANE_2_5GBPS) },
@@ -195,7 +195,11 @@ static void igb_process_mdd_event(struct igb_adapter *);
 #ifdef IFLA_VF_MAX
 static int igb_ndo_set_vf_mac( struct net_device *netdev, int vf, u8 *mac);
 static int igb_ndo_set_vf_vlan(struct net_device *netdev,
+#ifdef HAVE_VF_VLAN_PROTO
+                               int vf, u16 vlan, u8 qos, __be16 vlan_proto);
+#else
                                int vf, u16 vlan, u8 qos);
+#endif
 #ifdef HAVE_VF_SPOOFCHK_CONFIGURE
 static int igb_ndo_set_vf_spoofchk(struct net_device *netdev, int vf,
                                bool setting);
@@ -1027,8 +1031,15 @@ static void igb_set_interrupt_capability(struct igb_adapter *adapter, bool msix)
                        for (i = 0; i < numvecs; i++)
                                adapter->msix_entries[i].entry = i;
 
+#ifdef HAVE_PCI_ENABLE_MSIX
                        err = pci_enable_msix(pdev,
                                              adapter->msix_entries, numvecs);
+#else
+                       err = pci_enable_msix_range(pdev,
+                                       adapter->msix_entries,
+                                       numvecs,
+                                       numvecs);
+#endif
                        if (err == 0)
                                break;
                }
@@ -1122,7 +1133,7 @@ static int igb_alloc_q_vector(struct igb_adapter *adapter,
        /* initialize pointer to rings */
        ring = q_vector->ring;
 
-       /* intialize ITR */
+       /* initialize ITR */
        if (rxr_count) {
                /* rx or rx/tx vector */
                if (!adapter->rx_itr_setting || adapter->rx_itr_setting > 3)
@@ -1558,6 +1569,7 @@ static void igb_check_swap_media(struct igb_adapter *adapter)
        ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
        connsw = E1000_READ_REG(hw, E1000_CONNSW);
        link = igb_has_link(adapter);
+       (void) link;
 
        /* need to live swap if current media is copper and we have fiber/serdes
         * to go to.
@@ -1624,11 +1636,11 @@ static void igb_check_swap_media(struct igb_adapter *adapter)
  */
 static int igb_get_i2c_data(void *data)
 {
-       struct igb_adapter *adapter = (struct igb_adapter *)data;
+       struct igb_adapter *adapter = data;
        struct e1000_hw *hw = &adapter->hw;
        s32 i2cctl = E1000_READ_REG(hw, E1000_I2CPARAMS);
 
-       return ((i2cctl & E1000_I2C_DATA_IN) != 0);
+       return (i2cctl & E1000_I2C_DATA_IN) != 0;
 }
 
 /* igb_set_i2c_data - Sets the I2C data bit
@@ -1639,7 +1651,7 @@ static int igb_get_i2c_data(void *data)
  */
 static void igb_set_i2c_data(void *data, int state)
 {
-       struct igb_adapter *adapter = (struct igb_adapter *)data;
+       struct igb_adapter *adapter = data;
        struct e1000_hw *hw = &adapter->hw;
        s32 i2cctl = E1000_READ_REG(hw, E1000_I2CPARAMS);
 
@@ -1664,7 +1676,7 @@ static void igb_set_i2c_data(void *data, int state)
  */
 static void igb_set_i2c_clk(void *data, int state)
 {
-       struct igb_adapter *adapter = (struct igb_adapter *)data;
+       struct igb_adapter *adapter = data;
        struct e1000_hw *hw = &adapter->hw;
        s32 i2cctl = E1000_READ_REG(hw, E1000_I2CPARAMS);
 
@@ -1686,11 +1698,11 @@ static void igb_set_i2c_clk(void *data, int state)
  */
 static int igb_get_i2c_clk(void *data)
 {
-       struct igb_adapter *adapter = (struct igb_adapter *)data;
+       struct igb_adapter *adapter = data;
        struct e1000_hw *hw = &adapter->hw;
        s32 i2cctl = E1000_READ_REG(hw, E1000_I2CPARAMS);
 
-       return ((i2cctl & E1000_I2C_CLK_IN) != 0);
+       return (i2cctl & E1000_I2C_CLK_IN) != 0;
 }
 
 static const struct i2c_algo_bit_data igb_i2c_algo = {
@@ -2103,6 +2115,9 @@ static int igb_set_features(struct net_device *netdev,
 static int igb_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
                           struct net_device *dev,
                           const unsigned char *addr,
+#ifdef HAVE_NDO_FDB_ADD_VID
+                          u16 vid,
+#endif
                           u16 flags)
 #else
 static int igb_ndo_fdb_add(struct ndmsg *ndm,
@@ -2195,8 +2210,14 @@ static int igb_ndo_fdb_dump(struct sk_buff *skb,
 #endif /* USE_DEFAULT_FDB_DEL_DUMP */
 
 #ifdef HAVE_BRIDGE_ATTRIBS
+#ifdef HAVE_NDO_BRIDGE_SET_DEL_LINK_FLAGS
+static int igb_ndo_bridge_setlink(struct net_device *dev,
+                                 struct nlmsghdr *nlh,
+                                 u16 flags)
+#else
 static int igb_ndo_bridge_setlink(struct net_device *dev,
                                  struct nlmsghdr *nlh)
+#endif /* HAVE_NDO_BRIDGE_SET_DEL_LINK_FLAGS */
 {
        struct igb_adapter *adapter = netdev_priv(dev);
        struct e1000_hw *hw = &adapter->hw;
@@ -2241,8 +2262,14 @@ static int igb_ndo_bridge_setlink(struct net_device *dev,
 }
 
 #ifdef HAVE_BRIDGE_FILTER
+#ifdef HAVE_NDO_BRIDGE_GETLINK_NLFLAGS
+static int igb_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
+                                 struct net_device *dev, u32 filter_mask,
+                                 int nlflags)
+#else
 static int igb_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
                                  struct net_device *dev, u32 filter_mask)
+#endif /* HAVE_NDO_BRIDGE_GETLINK_NLFLAGS */
 #else
 static int igb_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
                                  struct net_device *dev)
@@ -2259,7 +2286,20 @@ static int igb_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
        else
                mode = BRIDGE_MODE_VEPA;
 
+#ifdef HAVE_NDO_DFLT_BRIDGE_ADD_MASK
+#ifdef HAVE_NDO_BRIDGE_GETLINK_NLFLAGS
+#ifdef HAVE_NDO_BRIDGE_GETLINK_FILTER_MASK_VLAN_FILL
+       return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode, 0, 0,
+                               nlflags, filter_mask, NULL);
+#else
+       return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode, 0, 0, nlflags);
+#endif /* HAVE_NDO_BRIDGE_GETLINK_FILTER_MASK_VLAN_FILL */
+#else
+       return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode, 0, 0);
+#endif /* HAVE_NDO_BRIDGE_GETLINK_NLFLAGS */
+#else
        return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode);
+#endif /* HAVE_NDO_DFLT_BRIDGE_ADD_MASK */
 }
 #endif /* HAVE_BRIDGE_ATTRIBS */
 #endif /* NTF_SELF */
@@ -3155,8 +3195,8 @@ static int igb_sw_init(struct igb_adapter *adapter)
                                     GFP_ATOMIC);
 
        /* Setup and initialize a copy of the hw vlan table array */
-       adapter->shadow_vfta = (u32 *)kzalloc(sizeof(u32) * E1000_VFTA_ENTRIES,
-                                       GFP_ATOMIC);
+       adapter->shadow_vfta = kzalloc(sizeof(u32) * E1000_VFTA_ENTRIES,
+                                      GFP_ATOMIC);
 #ifdef NO_KNI
        /* These calls may decrease the number of queues */
        if (hw->mac.type < e1000_i210) {
@@ -6383,7 +6423,11 @@ static void igb_set_vmvir(struct igb_adapter *adapter, u32 vid, u32 vf)
 }
 
 static int igb_ndo_set_vf_vlan(struct net_device *netdev,
+#ifdef HAVE_VF_VLAN_PROTO
+                              int vf, u16 vlan, u8 qos, __be16 vlan_proto)
+#else
                               int vf, u16 vlan, u8 qos)
+#endif
 {
        int err = 0;
        struct igb_adapter *adapter = netdev_priv(netdev);
@@ -6391,6 +6435,12 @@ static int igb_ndo_set_vf_vlan(struct net_device *netdev,
        /* VLAN IDs accepted range 0-4094 */
        if ((vf >= adapter->vfs_allocated_count) || (vlan > VLAN_VID_MASK-1) || (qos > 7))
                return -EINVAL;
+
+#ifdef HAVE_VF_VLAN_PROTO
+       if (vlan_proto != htons(ETH_P_8021Q))
+               return -EPROTONOSUPPORT;
+#endif
+
        if (vlan || qos) {
                err = igb_vlvf_set(adapter, vlan, !!vlan, vf);
                if (err)
@@ -6551,7 +6601,12 @@ static inline void igb_vf_reset(struct igb_adapter *adapter, u32 vf)
        if (adapter->vf_data[vf].pf_vlan)
                igb_ndo_set_vf_vlan(adapter->netdev, vf,
                                    adapter->vf_data[vf].pf_vlan,
+#ifdef HAVE_VF_VLAN_PROTO
+                                   adapter->vf_data[vf].pf_qos,
+                                   htons(ETH_P_8021Q));
+#else
                                    adapter->vf_data[vf].pf_qos);
+#endif
        else
                igb_clear_vf_vfta(adapter, vf);
 #endif
@@ -8016,7 +8071,7 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, int budget)
        igb_lro_flush_all(q_vector);
 
 #endif /* IGB_NO_LRO */
-       return (total_packets < budget);
+       return total_packets < budget;
 }
 #else /* CONFIG_IGB_DISABLE_PACKET_SPLIT */
 /**
@@ -8324,7 +8379,7 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, int budget)
        igb_lro_flush_all(q_vector);
 
 #endif /* IGB_NO_LRO */
-       return (total_packets < budget);
+       return total_packets < budget;
 }
 #endif /* CONFIG_IGB_DISABLE_PACKET_SPLIT */
 
@@ -9487,7 +9542,7 @@ static void igb_vmm_control(struct igb_adapter *adapter)
        }
 
                /* enable replication and loopback support */
-               count = adapter->vfs_allocated_count || adapter->vmdq_pools;
+               count = adapter->vfs_allocated_count || adapter->vmdq_pools;
                if (adapter->flags & IGB_FLAG_LOOPBACK_ENABLE && count)
                        e1000_vmdq_set_loopback_pf(hw, 1);
                e1000_vmdq_set_anti_spoofing_pf(hw,