Commit aae9bba5 authored by Chengchang Tang's avatar Chengchang Tang Committed by shiyongbang
Browse files

RDMA/hns: Support kernel ULP querying HW ID

driver inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8C2IP



--------------------------------------------------------------------------

Add API rdma_query_hw_id() to enable kernel-mode applications to
query the HW ID of the current device.

Signed-off-by: default avatarChengchang Tang <tangchengchang@huawei.com>
parent 85b26a97
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -70,3 +70,24 @@ u64 rdma_query_qp_db(struct ib_device *ib_dev, int qp_index)
}
EXPORT_SYMBOL(rdma_query_qp_db);

int rdma_query_hw_id(struct ib_device *ib_dev, u32 *chip_id,
		     u32 *die_id, u32 *func_id)
{
	struct hns_roce_dev *hr_dev = to_hr_dev(ib_dev);

	if (!is_hns_roce(ib_dev) || is_hns_roce_vf(hr_dev))
		return -EOPNOTSUPP;

	if (!chip_id || !die_id || !func_id)
		return -EINVAL;

	if (hr_dev->chip_id == HNS_IB_INVALID_ID)
		return -EINVAL;

	*chip_id = hr_dev->chip_id;
	*die_id = hr_dev->die_id;
	*func_id = hr_dev->func_id;
	return 0;
}
EXPORT_SYMBOL(rdma_query_hw_id);
+8 −0
Original line number Diff line number Diff line
@@ -32,4 +32,12 @@ bool rdma_support_stars(struct ib_device *ib_dev);
 */
u64 rdma_query_qp_db(struct ib_device *ib_dev, int qp_index);

/**
 * rdma_query_hw_id - Get the relevant hardware ID of the current device.
 * @chip_id - The ID of the chip where the current device is located.
 * @die_id - The ID of the IO DIE where the current device is located.
 * @func_id - The function ID of this device.
 */
int rdma_query_hw_id(struct ib_device *ib_dev, u32 *chip_id,
		     u32 *die_id, u32 *func_id);
#endif