From: Junxian Huang huangjunxian6@hisilicon.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I968IB
---------------------------------------------------------------
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 Signed-off-by: Juan Zhou zhoujuan51@h-partners.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 68bd08c87..d35ccaf56 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -260,6 +260,19 @@ static int hns_roce_query_device(struct ib_device *ib_dev, return 0; }
+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 hns_roce_query_port(struct ib_device *ib_dev, u32 port_num, struct ib_port_attr *props) { @@ -305,6 +318,11 @@ static int hns_roce_query_port(struct ib_device *ib_dev, u32 port_num, IB_PORT_PHYS_STATE_LINK_UP : IB_PORT_PHYS_STATE_DISABLED;
+ if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_BOND && + props->state == IB_PORT_ACTIVE) + props->state = get_upper_port_state(hr_dev); + + spin_unlock_irqrestore(&hr_dev->iboe.lock, flags);
return 0;