RDMA/providers: Simplify query_gid callback of RoCE providers
authorParav Pandit <parav@mellanox.com>
Sun, 1 Apr 2018 12:08:19 +0000 (15:08 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Wed, 4 Apr 2018 03:33:47 +0000 (21:33 -0600)
ib_query_gid() fetches the GID from the software cache maintained in
ib_core for RoCE ports.

Therefore, simplify the provider drivers for RoCE to treat query_gid()
callback as never called for RoCE, and only require non-RoCE devices to
implement it.

Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/device.c
drivers/infiniband/hw/bnxt_re/main.c
drivers/infiniband/hw/hns/hns_roce_main.c
drivers/infiniband/hw/mlx4/main.c
drivers/infiniband/hw/ocrdma/ocrdma_main.c
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
drivers/infiniband/hw/ocrdma/ocrdma_verbs.h
drivers/infiniband/hw/qedr/main.c
drivers/infiniband/hw/qedr/verbs.c
drivers/infiniband/hw/qedr/verbs.h
drivers/infiniband/sw/rxe/rxe_verbs.c

index dbe984f..5d79e8d 100644 (file)
@@ -103,7 +103,6 @@ static int ib_device_check_mandatory(struct ib_device *device)
                IB_MANDATORY_FUNC(query_device),
                IB_MANDATORY_FUNC(query_port),
                IB_MANDATORY_FUNC(query_pkey),
-               IB_MANDATORY_FUNC(query_gid),
                IB_MANDATORY_FUNC(alloc_pd),
                IB_MANDATORY_FUNC(dealloc_pd),
                IB_MANDATORY_FUNC(create_ah),
@@ -884,6 +883,9 @@ int ib_query_gid(struct ib_device *device,
        if (attr)
                return -EINVAL;
 
+       if (!device->query_gid)
+               return -EOPNOTSUPP;
+
        return device->query_gid(device, port_num, index, gid);
 }
 EXPORT_SYMBOL(ib_query_gid);
index abe0be8..f6c739e 100644 (file)
@@ -574,7 +574,6 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev)
        ibdev->get_port_immutable       = bnxt_re_get_port_immutable;
        ibdev->get_dev_fw_str           = bnxt_re_query_fw_str;
        ibdev->query_pkey               = bnxt_re_query_pkey;
-       ibdev->query_gid                = bnxt_re_query_gid;
        ibdev->get_netdev               = bnxt_re_get_netdev;
        ibdev->add_gid                  = bnxt_re_add_gid;
        ibdev->del_gid                  = bnxt_re_del_gid;
index 83e21f6..76e2e5b 100644 (file)
@@ -296,12 +296,6 @@ static enum rdma_link_layer hns_roce_get_link_layer(struct ib_device *device,
        return IB_LINK_LAYER_ETHERNET;
 }
 
-static int hns_roce_query_gid(struct ib_device *ib_dev, u8 port_num, int index,
-                             union ib_gid *gid)
-{
-       return 0;
-}
-
 static int hns_roce_query_pkey(struct ib_device *ib_dev, u8 port, u16 index,
                               u16 *pkey)
 {
@@ -482,7 +476,6 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
        ib_dev->modify_port             = hns_roce_modify_port;
        ib_dev->get_link_layer          = hns_roce_get_link_layer;
        ib_dev->get_netdev              = hns_roce_get_netdev;
-       ib_dev->query_gid               = hns_roce_query_gid;
        ib_dev->add_gid                 = hns_roce_add_gid;
        ib_dev->del_gid                 = hns_roce_del_gid;
        ib_dev->query_pkey              = hns_roce_query_pkey;
index d1be323..d9422a4 100644 (file)
@@ -888,24 +888,9 @@ out:
 static int mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
                             union ib_gid *gid)
 {
-       int ret;
-
        if (rdma_protocol_ib(ibdev, port))
                return __mlx4_ib_query_gid(ibdev, port, index, gid, 0);
-
-       if (!rdma_protocol_roce(ibdev, port))
-               return -ENODEV;
-
-       if (!rdma_cap_roce_gid_table(ibdev, port))
-               return -ENODEV;
-
-       ret = ib_get_cached_gid(ibdev, port, index, gid, NULL);
-       if (ret == -EAGAIN) {
-               memcpy(gid, &zgid, sizeof(*gid));
-               return 0;
-       }
-
-       return ret;
+       return 0;
 }
 
 static int mlx4_ib_query_sl2vl(struct ib_device *ibdev, u8 port, u64 *sl2vl_tbl)
index 4547aa2..eb8b6a9 100644 (file)
@@ -158,7 +158,6 @@ static int ocrdma_register_device(struct ocrdma_dev *dev)
        dev->ibdev.query_device = ocrdma_query_device;
        dev->ibdev.query_port = ocrdma_query_port;
        dev->ibdev.modify_port = ocrdma_modify_port;
-       dev->ibdev.query_gid = ocrdma_query_gid;
        dev->ibdev.get_netdev = ocrdma_get_netdev;
        dev->ibdev.get_link_layer = ocrdma_link_layer;
        dev->ibdev.alloc_pd = ocrdma_alloc_pd;
index 1e3dc92..784ed6b 100644 (file)
@@ -62,24 +62,6 @@ int ocrdma_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey)
        return 0;
 }
 
-int ocrdma_query_gid(struct ib_device *ibdev, u8 port,
-                    int index, union ib_gid *sgid)
-{
-       int ret;
-
-       memset(sgid, 0, sizeof(*sgid));
-       if (index >= OCRDMA_MAX_SGID)
-               return -EINVAL;
-
-       ret = ib_get_cached_gid(ibdev, port, index, sgid, NULL);
-       if (ret == -EAGAIN) {
-               memcpy(sgid, &zgid, sizeof(*sgid));
-               return 0;
-       }
-
-       return ret;
-}
-
 int ocrdma_query_device(struct ib_device *ibdev, struct ib_device_attr *attr,
                        struct ib_udata *uhw)
 {
index a48eab3..9a99717 100644 (file)
@@ -61,8 +61,6 @@ enum rdma_protocol_type
 ocrdma_query_protocol(struct ib_device *device, u8 port_num);
 
 void ocrdma_get_guid(struct ocrdma_dev *, u8 *guid);
-int ocrdma_query_gid(struct ib_device *, u8 port,
-                    int index, union ib_gid *gid);
 struct net_device *ocrdma_get_netdev(struct ib_device *device, u8 port_num);
 int ocrdma_query_pkey(struct ib_device *, u8 port, u16 index, u16 *pkey);
 
index d3ed711..e3bd2ca 100644 (file)
@@ -162,7 +162,6 @@ static int qedr_iw_register_device(struct qedr_dev *dev)
 static void qedr_roce_register_device(struct qedr_dev *dev)
 {
        dev->ibdev.node_type = RDMA_NODE_IB_CA;
-       dev->ibdev.query_gid = qedr_query_gid;
 
        dev->ibdev.get_port_immutable = qedr_roce_port_immutable;
 }
index 8587a68..ccc09a8 100644 (file)
@@ -84,27 +84,6 @@ int qedr_iw_query_gid(struct ib_device *ibdev, u8 port,
        return 0;
 }
 
-int qedr_query_gid(struct ib_device *ibdev, u8 port, int index,
-                  union ib_gid *sgid)
-{
-       struct qedr_dev *dev = get_qedr_dev(ibdev);
-       int rc = 0;
-
-       if (!rdma_cap_roce_gid_table(ibdev, port))
-               return -ENODEV;
-
-       rc = ib_get_cached_gid(ibdev, port, index, sgid, NULL);
-       if (rc == -EAGAIN) {
-               memcpy(sgid, &zgid, sizeof(*sgid));
-               return 0;
-       }
-
-       DP_DEBUG(dev, QEDR_MSG_INIT, "query gid: index=%d %llx:%llx\n", index,
-                sgid->global.interface_id, sgid->global.subnet_prefix);
-
-       return rc;
-}
-
 int qedr_query_device(struct ib_device *ibdev,
                      struct ib_device_attr *attr, struct ib_udata *udata)
 {
index b533049..2c57e4c 100644 (file)
@@ -38,7 +38,6 @@ int qedr_query_port(struct ib_device *, u8 port, struct ib_port_attr *props);
 int qedr_modify_port(struct ib_device *, u8 port, int mask,
                     struct ib_port_modify *props);
 
-int qedr_query_gid(struct ib_device *, u8 port, int index, union ib_gid *gid);
 int qedr_iw_query_gid(struct ib_device *ibdev, u8 port,
                      int index, union ib_gid *gid);
 
index 5ef8c33..f83bbf5 100644 (file)
@@ -77,23 +77,6 @@ out:
        return rc;
 }
 
-static int rxe_query_gid(struct ib_device *device,
-                        u8 port_num, int index, union ib_gid *gid)
-{
-       int ret;
-
-       if (index > RXE_PORT_GID_TBL_LEN)
-               return -EINVAL;
-
-       ret = ib_get_cached_gid(device, port_num, index, gid, NULL);
-       if (ret == -EAGAIN) {
-               memcpy(gid, &zgid, sizeof(*gid));
-               return 0;
-       }
-
-       return ret;
-}
-
 static int rxe_add_gid(struct ib_device *device, u8 port_num, unsigned int
                       index, const union ib_gid *gid,
                       const struct ib_gid_attr *attr, void **context)
@@ -1285,7 +1268,6 @@ int rxe_register_device(struct rxe_dev *rxe)
        dev->query_port = rxe_query_port;
        dev->modify_port = rxe_modify_port;
        dev->get_link_layer = rxe_get_link_layer;
-       dev->query_gid = rxe_query_gid;
        dev->get_netdev = rxe_get_netdev;
        dev->add_gid = rxe_add_gid;
        dev->del_gid = rxe_del_gid;