From: Lang Cheng <chenglang@xxxxxxxxxx> Support send link active event for every port of ib device except bonding backup port when ib device is being registered or deregistered. Signed-off-by: Lang Cheng <chenglang@xxxxxxxxxx> --- drivers/infiniband/core/device.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 0427a4d..6cdfffa 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -1341,6 +1341,7 @@ static int enable_device_and_get(struct ib_device *device) */ int ib_register_device(struct ib_device *device, const char *name) { + unsigned int port; int ret; ret = assign_name(device, name); @@ -1405,6 +1406,28 @@ int ib_register_device(struct ib_device *device, const char *name) } ib_device_put(device); + rdma_for_each_port(device, port) { + struct net_device *netdev = ib_device_get_netdev(device, port); + enum ib_port_state port_state; + struct ib_event event; + + /* not every port has a netdevice */ + if (!netdev || + ib_get_cached_port_inactive_status(device, port)) + continue; + + ib_get_cached_port_state(device, port, &port_state); + if (port_state != IB_PORT_ACTIVE) + continue; + + event.device = device; + event.event = IB_EVENT_PORT_ACTIVE; + event.element.port_num = port; + ib_dispatch_event(&event); + ibdev_dbg(device, "init event %s\n", + ib_event_msg(event.event)); + } + return 0; dev_cleanup: @@ -1469,6 +1492,27 @@ static void __ib_unregister_device(struct ib_device *ib_dev) */ void ib_unregister_device(struct ib_device *ib_dev) { + unsigned int port; + + rdma_for_each_port(ib_dev, port) { + enum ib_port_state port_state; + struct ib_event event; + + if (ib_get_cached_port_inactive_status(ib_dev, port)) + continue; + + ib_get_cached_port_state(ib_dev, port, &port_state); + if (port_state != IB_PORT_ACTIVE) + continue; + + event.device = ib_dev; + event.event = IB_EVENT_PORT_ERR; + event.element.port_num = port; + ib_dispatch_event(&event); + ibdev_dbg(ib_dev, "init event %s\n", + ib_event_msg(event.event)); + } + get_device(&ib_dev->dev); __ib_unregister_device(ib_dev); put_device(&ib_dev->dev); -- 2.8.1