aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Fastabend <john.r.fastabend@intel.com>2012-05-31 08:42:26 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2012-07-21 19:05:59 -0400
commit95447461fa9ae3d879c84c1d2f2f8da2fdcd8f34 (patch)
tree66288cc983efed26cf494915470dda8c80dbb6df
parentb92ad72dea9925359e9dfa70c4cbf8db6f1b2d65 (diff)
ixgbe: fix RAR entry counting for generic and fdb_add()
Do RAR entry accounting correctly so that errors are reported and promisc mode is set correctly when the number of entries exceeds the hardware limits. This can happen with many macvlan devices attached to the PF or by adding many fdb entries in SR-IOV modes. Also this includes a small refactor to fdb_add() to avoid having so many nested if/else statements after adding a check for the number or RAR entries. The max entries for the PF is currently 16 we allow 15 additional entries to account for the defined MAC. Signed-off-by: John Fastabend <john.r.fastabend@intel.com> Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com> Tested-by: Ross Brattain <ross.b.brattain@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index b376926af890..84370e78a0fb 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -3441,14 +3441,18 @@ static int ixgbe_write_uc_addr_list(struct net_device *netdev)
3441{ 3441{
3442 struct ixgbe_adapter *adapter = netdev_priv(netdev); 3442 struct ixgbe_adapter *adapter = netdev_priv(netdev);
3443 struct ixgbe_hw *hw = &adapter->hw; 3443 struct ixgbe_hw *hw = &adapter->hw;
3444 unsigned int rar_entries = IXGBE_MAX_PF_MACVLANS; 3444 unsigned int rar_entries = hw->mac.num_rar_entries - 1;
3445 int count = 0; 3445 int count = 0;
3446 3446
3447 /* In SR-IOV mode significantly less RAR entries are available */
3448 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
3449 rar_entries = IXGBE_MAX_PF_MACVLANS - 1;
3450
3447 /* return ENOMEM indicating insufficient memory for addresses */ 3451 /* return ENOMEM indicating insufficient memory for addresses */
3448 if (netdev_uc_count(netdev) > rar_entries) 3452 if (netdev_uc_count(netdev) > rar_entries)
3449 return -ENOMEM; 3453 return -ENOMEM;
3450 3454
3451 if (!netdev_uc_empty(netdev) && rar_entries) { 3455 if (!netdev_uc_empty(netdev)) {
3452 struct netdev_hw_addr *ha; 3456 struct netdev_hw_addr *ha;
3453 /* return error if we do not support writing to RAR table */ 3457 /* return error if we do not support writing to RAR table */
3454 if (!hw->mac.ops.set_rar) 3458 if (!hw->mac.ops.set_rar)
@@ -6861,7 +6865,10 @@ static int ixgbe_ndo_fdb_add(struct ndmsg *ndm,
6861 u16 flags) 6865 u16 flags)
6862{ 6866{
6863 struct ixgbe_adapter *adapter = netdev_priv(dev); 6867 struct ixgbe_adapter *adapter = netdev_priv(dev);
6864 int err = -EOPNOTSUPP; 6868 int err;
6869
6870 if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
6871 return -EOPNOTSUPP;
6865 6872
6866 if (ndm->ndm_state & NUD_PERMANENT) { 6873 if (ndm->ndm_state & NUD_PERMANENT) {
6867 pr_info("%s: FDB only supports static addresses\n", 6874 pr_info("%s: FDB only supports static addresses\n",
@@ -6869,13 +6876,17 @@ static int ixgbe_ndo_fdb_add(struct ndmsg *ndm,
6869 return -EINVAL; 6876 return -EINVAL;
6870 } 6877 }
6871 6878
6872 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) { 6879 if (is_unicast_ether_addr(addr)) {
6873 if (is_unicast_ether_addr(addr)) 6880 u32 rar_uc_entries = IXGBE_MAX_PF_MACVLANS;
6881
6882 if (netdev_uc_count(dev) < rar_uc_entries)
6874 err = dev_uc_add_excl(dev, addr); 6883 err = dev_uc_add_excl(dev, addr);
6875 else if (is_multicast_ether_addr(addr))
6876 err = dev_mc_add_excl(dev, addr);
6877 else 6884 else
6878 err = -EINVAL; 6885 err = -ENOMEM;
6886 } else if (is_multicast_ether_addr(addr)) {
6887 err = dev_mc_add_excl(dev, addr);
6888 } else {
6889 err = -EINVAL;
6879 } 6890 }
6880 6891
6881 /* Only return duplicate errors if NLM_F_EXCL is set */ 6892 /* Only return duplicate errors if NLM_F_EXCL is set */