remove extra parentheses in return statement
[dpdk.git] / lib / librte_eal / linuxapp / kni / ethtool / igb / igb_main.c
index 6388207..96acec5 100644 (file)
@@ -200,7 +200,11 @@ static int igb_ndo_set_vf_vlan(struct net_device *netdev,
 static int igb_ndo_set_vf_spoofchk(struct net_device *netdev, int vf,
                                bool setting);
 #endif
+#ifdef HAVE_VF_MIN_MAX_TXRATE
+static int igb_ndo_set_vf_bw(struct net_device *, int, int, int);
+#else /* HAVE_VF_MIN_MAX_TXRATE */
 static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate);
+#endif /* HAVE_VF_MIN_MAX_TXRATE */
 static int igb_ndo_get_vf_config(struct net_device *netdev, int vf,
                                 struct ifla_vf_info *ivi);
 static void igb_check_vf_rate_limit(struct igb_adapter *);
@@ -1007,7 +1011,7 @@ static void igb_set_interrupt_capability(struct igb_adapter *adapter, bool msix)
                /* start with one vector for every rx queue */
                numvecs = adapter->num_rx_queues;
 
-               /* if tx handler is seperate add 1 for every tx queue */
+               /* if tx handler is separate add 1 for every tx queue */
                if (!(adapter->flags & IGB_FLAG_QUEUE_PAIRS))
                        numvecs += adapter->num_tx_queues;
 
@@ -1624,7 +1628,7 @@ static int igb_get_i2c_data(void *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
@@ -1686,7 +1690,7 @@ static int igb_get_i2c_clk(void *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 = {
@@ -2099,6 +2103,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,
@@ -2191,8 +2198,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;
@@ -2237,8 +2250,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)
@@ -2255,7 +2274,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 */
@@ -2278,7 +2310,11 @@ static const struct net_device_ops igb_netdev_ops = {
 #ifdef IFLA_VF_MAX
        .ndo_set_vf_mac         = igb_ndo_set_vf_mac,
        .ndo_set_vf_vlan        = igb_ndo_set_vf_vlan,
+#ifdef HAVE_VF_MIN_MAX_TXRATE
+       .ndo_set_vf_rate        = igb_ndo_set_vf_bw,
+#else /* HAVE_VF_MIN_MAX_TXRATE */
        .ndo_set_vf_tx_rate     = igb_ndo_set_vf_bw,
+#endif /* HAVE_VF_MIN_MAX_TXRATE */
        .ndo_get_vf_config      = igb_ndo_get_vf_config,
 #ifdef HAVE_VF_SPOOFCHK_CONFIGURE
        .ndo_set_vf_spoofchk    = igb_ndo_set_vf_spoofchk,
@@ -2294,12 +2330,14 @@ static const struct net_device_ops igb_netdev_ops = {
 #ifdef HAVE_VLAN_RX_REGISTER
        .ndo_vlan_rx_register   = igb_vlan_mode,
 #endif
+#ifndef HAVE_RHEL6_NETDEV_OPS_EXT_FDB
 #ifdef NTF_SELF
        .ndo_fdb_add            = igb_ndo_fdb_add,
 #ifndef USE_DEFAULT_FDB_DEL_DUMP
        .ndo_fdb_del            = igb_ndo_fdb_del,
        .ndo_fdb_dump           = igb_ndo_fdb_dump,
 #endif
+#endif /* ! HAVE_RHEL6_NETDEV_OPS_EXT_FDB */
 #ifdef HAVE_BRIDGE_ATTRIBS
        .ndo_bridge_setlink     = igb_ndo_bridge_setlink,
        .ndo_bridge_getlink     = igb_ndo_bridge_getlink,
@@ -3145,8 +3183,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) {
@@ -8006,7 +8044,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 */
 /**
@@ -8314,7 +8352,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 */
 
@@ -9387,7 +9425,12 @@ static void igb_check_vf_rate_limit(struct igb_adapter *adapter)
        }
 }
 
+#ifdef HAVE_VF_MIN_MAX_TXRATE
+static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int min_tx_rate,
+                            int tx_rate)
+#else /* HAVE_VF_MIN_MAX_TXRATE */
 static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate)
+#endif /* HAVE_VF_MIN_MAX_TXRATE */
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
@@ -9396,6 +9439,11 @@ static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate)
        if (hw->mac.type != e1000_82576)
                return -EOPNOTSUPP;
 
+#ifdef HAVE_VF_MIN_MAX_TXRATE
+       if (min_tx_rate)
+               return -EINVAL;
+#endif /* HAVE_VF_MIN_MAX_TXRATE */
+
        actual_link_speed = igb_link_mbps(adapter->link_speed);
        if ((vf >= adapter->vfs_allocated_count) ||
                (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) ||
@@ -9417,7 +9465,12 @@ static int igb_ndo_get_vf_config(struct net_device *netdev,
                return -EINVAL;
        ivi->vf = vf;
        memcpy(&ivi->mac, adapter->vf_data[vf].vf_mac_addresses, ETH_ALEN);
+#ifdef HAVE_VF_MIN_MAX_TXRATE
+       ivi->max_tx_rate = adapter->vf_data[vf].tx_rate;
+       ivi->min_tx_rate = 0;
+#else /* HAVE_VF_MIN_MAX_TXRATE */
        ivi->tx_rate = adapter->vf_data[vf].tx_rate;
+#endif /* HAVE_VF_MIN_MAX_TXRATE */
        ivi->vlan = adapter->vf_data[vf].pf_vlan;
        ivi->qos = adapter->vf_data[vf].pf_qos;
 #ifdef HAVE_VF_SPOOFCHK_CONFIGURE
@@ -9462,7 +9515,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,