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: bca9ff271249 ("RDMA/hns: Add method for shrinking DCA memory pool") Fixes: d8cca476a8d2 ("RDMA/hns: Add method for attaching WQE buffer") Fixes: 0273952c5e6e ("RDMA/hns: Add method to detach WQE buffer") Fixes: f0384ddcf1ee ("RDMA/hns: Add method to query WQE buffer's address") Signed-off-by: Chengchang Tang tangchengchang@huawei.com --- drivers/infiniband/hw/hns/hns_roce_dca.c | 72 +++++++++++++----------- 1 file changed, 40 insertions(+), 32 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_dca.c b/drivers/infiniband/hw/hns/hns_roce_dca.c index 4d3e52dd5..49adf4326 100644 --- a/drivers/infiniband/hw/hns/hns_roce_dca.c +++ b/drivers/infiniband/hw/hns/hns_roce_dca.c @@ -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;