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 dbe984faed65cdd5dc3c68f0fec04db7c1199831..5d79e8de31f56493257a33405ace6a48236bafe6 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 abe0be8b5ddcda0a5040d5893085303e9961b77c..f6c739ec8b620bb30dd6501b4c65433f2950fa31 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 83e21f696bbc78a8d3b53038924cfd0848103641..76e2e5b418951a26d3b4b68900fef6757279b819 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 d1be3231f4f0b7c5e947ce3d04717d367ea302a2..d9422a44549e4366bcb92d7ac441e09298b194ca 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 4547aa28d4aeca8f25e89b22168169aecba89af1..eb8b6a935016e4bfd8fac97c8bad28ef8a7fa8ce 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 1e3dc92bc37bea403341feb4946aac56384ed713..784ed6b09a469e6526b7049037b248be65786837 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 a48eab35861feeb407500f44ed7d215986b0d016..9a99717086460a2549543635aa0e9df00343954d 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 d3ed711b8f923f5c1aaa8aa97419bc13f68eea13..e3bd2ca8968d182d5f089ff63848f7a30b4a06ab 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 8587a6840c105e7ff4ad81e5120a6ece38ba6ede..ccc09a8e4195fa505a845668476b2be3c298ecca 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 b5330495bf7c9c9d1307f117cdf883e8c255de57..2c57e4c592a680cce83e10fa912ded33a8de219d 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 5ef8c3333e43959e9b970500d7a3a0295e2a1fbf..f83bbf550ec0f30915e987b3345c0ef63421c088 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;