]> www.infradead.org Git - linux.git/commitdiff
RDMA/pvrdma: Support report_port_event() ops
authorYuyu Li <liyuyu6@huawei.com>
Fri, 22 Nov 2024 10:53:06 +0000 (18:53 +0800)
committerLeon Romanovsky <leon@kernel.org>
Thu, 26 Dec 2024 04:39:11 +0000 (23:39 -0500)
In addition to dispatching event, some private stuffs need to be
done in this driver's link status event handler. Implement the new
report_port_event() ops with the link status event codes.

Signed-off-by: Yuyu Li <liyuyu6@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c

index 768aad364c89f768d56d4dc13de2d5b900f6e7b3..1664d1d7d96963f09c18f8d96f704a6024046eef 100644 (file)
@@ -143,6 +143,46 @@ static int pvrdma_port_immutable(struct ib_device *ibdev, u32 port_num,
        return 0;
 }
 
+static void pvrdma_dispatch_event(struct pvrdma_dev *dev, int port,
+                                 enum ib_event_type event)
+{
+       struct ib_event ib_event;
+
+       memset(&ib_event, 0, sizeof(ib_event));
+       ib_event.device = &dev->ib_dev;
+       ib_event.element.port_num = port;
+       ib_event.event = event;
+       ib_dispatch_event(&ib_event);
+}
+
+static void pvrdma_report_event_handle(struct ib_device *ibdev,
+                                      struct net_device *ndev,
+                                      unsigned long event)
+{
+       struct pvrdma_dev *dev = container_of(ibdev, struct pvrdma_dev, ib_dev);
+
+       switch (event) {
+       case NETDEV_DOWN:
+               pvrdma_dispatch_event(dev, 1, IB_EVENT_PORT_ERR);
+               break;
+       case NETDEV_UP:
+               pvrdma_write_reg(dev, PVRDMA_REG_CTL,
+                                PVRDMA_DEVICE_CTL_UNQUIESCE);
+
+               mb();
+
+               if (pvrdma_read_reg(dev, PVRDMA_REG_ERR))
+                       dev_err(&dev->pdev->dev,
+                               "failed to activate device during link up\n");
+               else
+                       pvrdma_dispatch_event(dev, 1, IB_EVENT_PORT_ACTIVE);
+               break;
+
+       default:
+               break;
+       }
+}
+
 static const struct ib_device_ops pvrdma_dev_ops = {
        .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_VMW_PVRDMA,
@@ -181,6 +221,7 @@ static const struct ib_device_ops pvrdma_dev_ops = {
        .query_qp = pvrdma_query_qp,
        .reg_user_mr = pvrdma_reg_user_mr,
        .req_notify_cq = pvrdma_req_notify_cq,
+       .report_port_event = pvrdma_report_event_handle,
 
        INIT_RDMA_OBJ_SIZE(ib_ah, pvrdma_ah, ibah),
        INIT_RDMA_OBJ_SIZE(ib_cq, pvrdma_cq, ibcq),
@@ -362,18 +403,6 @@ static void pvrdma_srq_event(struct pvrdma_dev *dev, u32 srqn, int type)
        }
 }
 
-static void pvrdma_dispatch_event(struct pvrdma_dev *dev, int port,
-                                 enum ib_event_type event)
-{
-       struct ib_event ib_event;
-
-       memset(&ib_event, 0, sizeof(ib_event));
-       ib_event.device = &dev->ib_dev;
-       ib_event.element.port_num = port;
-       ib_event.event = event;
-       ib_dispatch_event(&ib_event);
-}
-
 static void pvrdma_dev_event(struct pvrdma_dev *dev, u8 port, int type)
 {
        if (port < 1 || port > dev->dsr->caps.phys_port_cnt) {
@@ -666,21 +695,8 @@ static void pvrdma_netdevice_event_handle(struct pvrdma_dev *dev,
 
        switch (event) {
        case NETDEV_REBOOT:
-       case NETDEV_DOWN:
                pvrdma_dispatch_event(dev, 1, IB_EVENT_PORT_ERR);
                break;
-       case NETDEV_UP:
-               pvrdma_write_reg(dev, PVRDMA_REG_CTL,
-                                PVRDMA_DEVICE_CTL_UNQUIESCE);
-
-               mb();
-
-               if (pvrdma_read_reg(dev, PVRDMA_REG_ERR))
-                       dev_err(&dev->pdev->dev,
-                               "failed to activate device during link up\n");
-               else
-                       pvrdma_dispatch_event(dev, 1, IB_EVENT_PORT_ACTIVE);
-               break;
        case NETDEV_UNREGISTER:
                ib_device_set_netdev(&dev->ib_dev, NULL, 1);
                dev_put(dev->netdev);