From: Junxian Huang huangjunxian6@hisilicon.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I6ZAIM
---------------------------------------------------------------
For RoCE bonding, the IB port state should depend on the link status of upper device. When the upper device is link up, the IB port state should be IB_PORT_ATIVE; otherwise, the state should be IB_PORT_DOWN.
Particularly, when all slaves are link down, the upper device will become link down automatically, and when at least one slave become link up, the upper device will become link up. In these situations the IB port will also change accordingly.
Signed-off-by: Junxian Huang huangjunxian6@hisilicon.com --- drivers/infiniband/hw/hns/hns_roce_main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index d8d402627b14..075d31d7f00c 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -118,6 +118,19 @@ static int hns_roce_del_gid(const struct ib_gid_attr *attr, void **context) return ret; }
+static enum ib_port_state get_upper_port_state(struct hns_roce_dev *hr_dev) +{ + struct hns_roce_bond_group *bond_grp; + struct net_device *upper; + + bond_grp = hns_roce_get_bond_grp(hr_dev); + upper = bond_grp ? bond_grp->upper_dev : NULL; + if (upper) + return get_port_state(upper); + + return IB_PORT_ACTIVE; +} + static int handle_en_event(struct hns_roce_dev *hr_dev, u8 port, unsigned long dev_event) { @@ -301,6 +314,11 @@ static int hns_roce_query_port(struct ib_device *ib_dev, u8 port_num, mtu = iboe_get_mtu(net_dev->mtu); props->active_mtu = mtu ? min(props->max_mtu, mtu) : IB_MTU_256; props->state = get_port_state(net_dev); + + if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_BOND && + props->state == IB_PORT_ACTIVE) + props->state = get_upper_port_state(hr_dev); + props->phys_state = props->state == IB_PORT_ACTIVE ? IB_PORT_PHYS_STATE_LINK_UP : IB_PORT_PHYS_STATE_DISABLED;