From: Junxian Huang huangjunxian6@hisilicon.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I6Z4E9
---------------------------------------------------------------
Currently, the driver will count the number of slave hr_dev, but during bond clearing event and slave decreasing event, only one slave has a corresponding hr_dev, and the number will always be 1. It causes that all slave decrease events are redirected to a bond clearing operation.
This patch fixes this problem by counting slave netdev directly instead of getting its hr_dev during bond clearing event and slave decreasing event.
Fixes: 646b97dbb8dc ("RDMA/hns: adjust the structure of RoCE bonding driver") Signed-off-by: Junxian Huang huangjunxian6@hisilicon.com --- drivers/infiniband/hw/hns/hns_roce_bond.c | 24 ++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_bond.c b/drivers/infiniband/hw/hns/hns_roce_bond.c index 43c7266f0fb3..200d12c3ff2d 100644 --- a/drivers/infiniband/hw/hns/hns_roce_bond.c +++ b/drivers/infiniband/hw/hns/hns_roce_bond.c @@ -661,15 +661,21 @@ static enum bond_support_type
rcu_read_lock(); for_each_netdev_in_bond_rcu(*upper_dev, net_dev) { - hr_dev = hns_roce_get_hrdev_by_netdev(net_dev); - if (hr_dev) { - slave_num++; - if (bus_num == -1) - bus_num = hr_dev->pci_dev->bus->number; - if (hr_dev->is_vf || pci_num_vf(hr_dev->pci_dev) > 0 || - bus_num != hr_dev->pci_dev->bus->number) { - support = false; - break; + if (!info->linking && bond_grp_exist) { + if (is_netdev_bond_slave(net_dev, bond_grp)) + slave_num++; + } else { + hr_dev = hns_roce_get_hrdev_by_netdev(net_dev); + if (hr_dev) { + slave_num++; + if (bus_num == -1) + bus_num = hr_dev->pci_dev->bus->number; + if (hr_dev->is_vf || + pci_num_vf(hr_dev->pci_dev) > 0 || + bus_num != hr_dev->pci_dev->bus->number) { + support = false; + break; + } } } }