From: Junxian Huang huangjunxian6@hisilicon.com
driver inclusion category: cleanup bugzilla: https://gitee.com/openeuler/kernel/issues/I8LY0D
--------------------------------------------------------------------------
Add check for the following bonding-unsupported cases: 1. non-hns slaves 2. hns slaves without setting bonding cap_flag 3. unsupported hash type
Fixes: 6ba084e0f031 ("RDMA/hns: add constraints for bonding-unsupported situations") Signed-off-by: Junxian Huang huangjunxian6@hisilicon.com --- drivers/infiniband/hw/hns/hns_roce_bond.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_bond.c b/drivers/infiniband/hw/hns/hns_roce_bond.c index 060b07bfeb3d..2923acb810bd 100644 --- a/drivers/infiniband/hw/hns/hns_roce_bond.c +++ b/drivers/infiniband/hw/hns/hns_roce_bond.c @@ -658,10 +658,17 @@ static bool hns_roce_bond_lowerstate_event(struct hns_roce_dev *hr_dev, return true; }
-static inline bool hns_roce_bond_mode_is_supported(enum netdev_lag_tx_type tx_type) +static bool is_bond_setting_supported(struct netdev_lag_upper_info *bond_info) { - if (tx_type != NETDEV_LAG_TX_TYPE_ACTIVEBACKUP && - tx_type != NETDEV_LAG_TX_TYPE_HASH) + if (!bond_info) + return false; + + if (bond_info->tx_type != NETDEV_LAG_TX_TYPE_ACTIVEBACKUP && + bond_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) + return false; + + if (bond_info->tx_type == NETDEV_LAG_TX_TYPE_HASH && + bond_info->hash_type > NETDEV_LAG_HASH_L23) return false;
return true; @@ -783,9 +790,9 @@ static struct hns_roce_bond_group *hns_roce_alloc_bond_grp(struct hns_roce_dev * return bond_grp; }
-static bool is_dev_bond_supported(struct hns_roce_dev *hr_dev, int *bus_num) +static bool is_dev_bond_supported(struct hns_roce_dev *hr_dev, int bus_num) { - if (!hr_dev) + if (!hr_dev || !(hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_BOND)) return false;
if (hr_dev->is_vf || pci_num_vf(hr_dev->pci_dev) > 0) @@ -820,7 +827,7 @@ static bool check_linking_bond_support(struct netdev_lag_upper_info *bond_info, struct net_device *net_dev; u8 slave_num = 0;
- if (!hns_roce_bond_mode_is_supported(bond_info->tx_type)) + if (!is_bond_setting_supported(bond_info)) return false;
rcu_read_lock();