Commit ff2936dd authored by Chengchang Tang's avatar Chengchang Tang Committed by Juan Zhou
Browse files

RDMA/hns: Fix DCA's dependence on ib_uverbs

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9CK0O



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

Currently, compiling DCA strongly relies on ib_uverbs. If ib_uverbs is
not configured, it will cause the entire hns-roce-hw-v2 compilation to
fail.

This patch isolates the parts of the DCA code that rely on ib_uverbs
to fix this problem.

Fixes: bca9ff27 ("RDMA/hns: Add method for shrinking DCA memory pool")
Fixes: d8cca476 ("RDMA/hns: Add method for attaching WQE buffer")
Fixes: 0273952c ("RDMA/hns: Add method to detach WQE buffer")
Fixes: f0384ddc ("RDMA/hns: Add method to query WQE buffer's address")
Signed-off-by: default avatarChengchang Tang <tangchengchang@huawei.com>
parent fca88ab0
Loading
Loading
Loading
Loading
+40 −32
Original line number Diff line number Diff line
@@ -604,38 +604,6 @@ struct dca_page_query_active_attr {
	u64 mem_key;
};

static int query_dca_active_pages_proc(struct dca_mem *mem, int index,
				       void *param)
{
	struct hns_dca_page_state *state = &mem->states[index];
	struct dca_page_query_active_attr *attr = param;

	if (!dca_page_is_active(state, attr->buf_id))
		return 0;

	if (attr->curr_index < attr->start_index) {
		attr->curr_index++;
		return 0;
	} else if (attr->curr_index > attr->start_index) {
		return DCA_MEM_STOP_ITERATE;
	}

	/* Search first page in DCA mem */
	attr->page_index = index;
	attr->mem_key = mem->key;
	/* Search active pages in continuous addresses */
	while (index < mem->page_count) {
		state = &mem->states[index];
		if (!dca_page_is_active(state, attr->buf_id))
			break;

		index++;
		attr->page_count++;
	}

	return DCA_MEM_STOP_ITERATE;
}

static int sync_dca_buf_offset(struct hns_roce_dev *hr_dev,
			       struct hns_roce_qp *hr_qp,
			       struct hns_dca_attach_attr *attr)
@@ -1542,6 +1510,7 @@ uverbs_attr_to_hr_uctx(struct uverbs_attr_bundle *attrs)
					 struct hns_roce_ucontext, ibucontext);
}

#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
static int UVERBS_HANDLER(HNS_IB_METHOD_DCA_MEM_REG)(
	struct uverbs_attr_bundle *attrs)
{
@@ -1753,6 +1722,38 @@ DECLARE_UVERBS_NAMED_METHOD(
	UVERBS_ATTR_PTR_IN(HNS_IB_ATTR_DCA_MEM_DETACH_SQ_INDEX,
			   UVERBS_ATTR_TYPE(u32), UA_MANDATORY));

static int query_dca_active_pages_proc(struct dca_mem *mem, int index,
				       void *param)
{
	struct hns_dca_page_state *state = &mem->states[index];
	struct dca_page_query_active_attr *attr = param;

	if (!dca_page_is_active(state, attr->buf_id))
		return 0;

	if (attr->curr_index < attr->start_index) {
		attr->curr_index++;
		return 0;
	} else if (attr->curr_index > attr->start_index) {
		return DCA_MEM_STOP_ITERATE;
	}

	/* Search first page in DCA mem */
	attr->page_index = index;
	attr->mem_key = mem->key;
	/* Search active pages in continuous addresses */
	while (index < mem->page_count) {
		state = &mem->states[index];
		if (!dca_page_is_active(state, attr->buf_id))
			break;

		index++;
		attr->page_count++;
	}

	return DCA_MEM_STOP_ITERATE;
}

static int UVERBS_HANDLER(HNS_IB_METHOD_DCA_MEM_QUERY)(
	struct uverbs_attr_bundle *attrs)
{
@@ -1836,6 +1837,13 @@ const struct uapi_definition hns_roce_dca_uapi_defs[] = {
	{}
};

#else

const struct uapi_definition hns_roce_dca_uapi_defs[] = {
};

#endif

/* enum DCA pool */
struct dca_mem_enum_attr {
	void *param;