@@ -240,11 +240,11 @@ static int query_sysfs_gid_entry(struct ibv_context *context, uint32_t port_num,
entry->gid_index = gid_index;
entry->port_num = port_num;
- ret = ibv_query_gid(context, port_num, gid_index, &entry->gid);
+ ret = _ibv_query_gid(context, port_num, gid_index, &entry->gid);
if (ret)
return EINVAL;
- ret = ibv_query_gid_type(context, port_num, gid_index, &gid_type);
+ ret = _ibv_query_gid_type(context, port_num, gid_index, &gid_type);
if (ret)
return EINVAL;
@@ -659,6 +659,12 @@ static inline bool check_comp_mask(uint64_t input, uint64_t supported)
int ibv_query_gid_type(struct ibv_context *context, uint8_t port_num,
unsigned int index, enum ibv_gid_type_sysfs *type);
+int _ibv_query_gid_type(struct ibv_context *context, uint8_t port_num,
+ unsigned int index, enum ibv_gid_type_sysfs *type);
+
+int _ibv_query_gid(struct ibv_context *context, uint8_t port_num, int index,
+ union ibv_gid *gid);
+
static inline int
ibv_check_alloc_parent_domain(struct ibv_parent_domain_init_attr *attr)
{
@@ -216,10 +216,8 @@ LATEST_SYMVER_FUNC(ibv_query_port, 1_1, "IBVERBS_1.1",
sizeof(*port_attr));
}
-LATEST_SYMVER_FUNC(ibv_query_gid, 1_1, "IBVERBS_1.1",
- int,
- struct ibv_context *context, uint8_t port_num,
- int index, union ibv_gid *gid)
+int _ibv_query_gid(struct ibv_context *context, uint8_t port_num, int index,
+ union ibv_gid *gid)
{
struct verbs_device *verbs_device = verbs_get_device(context->device);
char attr[41];
@@ -240,6 +238,29 @@ LATEST_SYMVER_FUNC(ibv_query_gid, 1_1, "IBVERBS_1.1",
return 0;
}
+LATEST_SYMVER_FUNC(ibv_query_gid, 1_1, "IBVERBS_1.1",
+ int,
+ struct ibv_context *context, uint8_t port_num,
+ int index, union ibv_gid *gid)
+{
+ struct ibv_gid_entry entry = {};
+ int ret;
+
+ ret = ibv_cmd_query_gid_entry(context, port_num, index, &entry, 0,
+ sizeof(entry));
+ /* Preserve API behavior for empty GID */
+ if (ret == ENODATA) {
+ memset(gid, 0, sizeof(*gid));
+ return 0;
+ }
+ if (ret)
+ return -1;
+
+ memcpy(gid, &entry.gid, sizeof(entry.gid));
+
+ return 0;
+}
+
int _ibv_query_gid_ex(struct ibv_context *context, uint32_t port_num,
uint32_t gid_index, struct ibv_gid_entry *entry,
uint32_t flags, size_t entry_size)
@@ -711,8 +732,8 @@ LATEST_SYMVER_FUNC(ibv_create_ah, 1_1, "IBVERBS_1.1",
*/
#define V1_TYPE "IB/RoCE v1"
#define V2_TYPE "RoCE v2"
-int ibv_query_gid_type(struct ibv_context *context, uint8_t port_num,
- unsigned int index, enum ibv_gid_type_sysfs *type)
+int _ibv_query_gid_type(struct ibv_context *context, uint8_t port_num,
+ unsigned int index, enum ibv_gid_type_sysfs *type)
{
struct verbs_device *verbs_device = verbs_get_device(context->device);
char buff[11];
@@ -768,6 +789,31 @@ int ibv_query_gid_type(struct ibv_context *context, uint8_t port_num,
return 0;
}
+int ibv_query_gid_type(struct ibv_context *context, uint8_t port_num,
+ unsigned int index, enum ibv_gid_type_sysfs *type)
+{
+ struct ibv_gid_entry entry = {};
+ int ret;
+
+ ret = ibv_cmd_query_gid_entry(context, port_num, index, &entry, 0,
+ sizeof(entry));
+ /* Preserve API behavior for empty GID */
+ if (ret == ENODATA) {
+ *type = IBV_GID_TYPE_SYSFS_IB_ROCE_V1;
+ return 0;
+ }
+ if (ret)
+ return -1;
+
+ if (entry.gid_type == IBV_GID_TYPE_IB ||
+ entry.gid_type == IBV_GID_TYPE_ROCE_V1)
+ *type = IBV_GID_TYPE_SYSFS_IB_ROCE_V1;
+ else
+ *type = IBV_GID_TYPE_SYSFS_ROCE_V2;
+
+ return 0;
+}
+
static int ibv_find_gid_index(struct ibv_context *context, uint8_t port_num,
union ibv_gid *gid,
enum ibv_gid_type_sysfs gid_type)