mirror of
https://github.com/torvalds/linux.git
synced 2026-07-31 11:37:06 +02:00
RDMA/pvrdma: Support report_port_event() ops
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>
This commit is contained in:
parent
e4b4ef3457
commit
e89fd16278
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user