Commit 01c810c8 authored by Junxian Huang's avatar Junxian Huang Committed by ZhouJuan
Browse files

RDMA/hns: Fix the counting error of slave number

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: 646b97db ("RDMA/hns: adjust the structure of RoCE bonding driver")
Signed-off-by: default avatarJunxian Huang <huangjunxian6@hisilicon.com>
parent 8d3ee0ae
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -661,18 +661,24 @@ static enum bond_support_type

	rcu_read_lock();
	for_each_netdev_in_bond_rcu(*upper_dev, net_dev) {
		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 ||
				if (hr_dev->is_vf ||
				    pci_num_vf(hr_dev->pci_dev) > 0 ||
				    bus_num != hr_dev->pci_dev->bus->number) {
					support = false;
					break;
				}
			}
		}
	}
	rcu_read_unlock();

	if (slave_num <= 1)