diff --git a/0017-verbs-Add-generic-logging-API.patch b/0017-verbs-Add-generic-logging-API.patch new file mode 100644 index 0000000000000000000000000000000000000000..6734c8fcd24fd00cb7fdada3b79b75f35fcef08b --- /dev/null +++ b/0017-verbs-Add-generic-logging-API.patch @@ -0,0 +1,258 @@ +From 1ea1524950b8bc4e4dfe06865e1e5c47a657b6e4 Mon Sep 17 00:00:00 2001 +From: Gal Pressman +Date: Sun, 6 Jun 2021 14:48:07 +0300 +Subject: verbs: Add generic logging API + +A debug prints mechanism is useful when debugging application failures. +This patch adds a generic API that can be used by all providers and +replace provider-specific counterparts. + +The debug messages are controlled through an environment variable named +VERBS_LOG_LEVEL, where the value indicates which prints should be +enabled: + +enum { + VERBS_LOG_LEVEL_NONE, + VERBS_LOG_ERR, + VERBS_LOG_WARN, + VERBS_LOG_INFO, + VERBS_LOG_DEBUG, +}; + +For example, to enable prints with level warn or higher, VERBS_LOG_LEVEL +shall be set to 2. + +The output shall be written to the file provided in the VERBS_LOG_FILE +environment variable. When the library is compiled in debug mode and no +file is provided the output shall be written to stderr. + +For data-path flows, where the overhead of the additional if statement +matters, the verbs_*_datapath() macros can be used, which will be +compiled out when the library is compiled for release. + +Signed-off-by: Gal Pressman +--- + Documentation/libibverbs.md | 18 ++++++++++ + buildlib/RDMA_BuildType.cmake | 4 +++ + libibverbs/driver.h | 50 +++++++++++++++++++++++++++ + libibverbs/init.c | 65 +++++++++++++++++++++++++++++++++++ + libibverbs/libibverbs.map.in | 1 + + 5 files changed, 138 insertions(+) + +diff --git a/Documentation/libibverbs.md b/Documentation/libibverbs.md +index cbe076e..980f354 100644 +--- a/Documentation/libibverbs.md ++++ b/Documentation/libibverbs.md +@@ -56,3 +56,21 @@ need to increase this limit. This is usually done for ordinary users + via the file /etc/security/limits.conf. More configuration may be + necessary if you are logging in via OpenSSH and your sshd is + configured to use privilege separation. ++ ++# Debugging ++ ++### Enabling debug prints ++ ++Library and providers debug prints can be enabled using the `VERBS_LOG_LEVEL` ++environment variable, the output shall be written to the file provided in the ++`VERBS_LOG_FILE` environment variable. When the library is compiled in debug ++mode and no file is provided the output will be written to stderr. ++ ++Note: some of the debug prints are only available when the library is compiled ++in debug mode. ++ ++The following table describes the expected behavior when VERBS_LOG_LEVEL is set: ++| | Release | Debug | ++|-----------------|---------------------------------|------------------------------------------------| ++| Regular prints | Output to VERBS_LOG_FILE if set | Output to VERBS_LOG_FILE, or stderr if not set | ++| Datapath prints | Compiled out, no output | Output to VERBS_LOG_FILE, or stderr if not set | +diff --git a/buildlib/RDMA_BuildType.cmake b/buildlib/RDMA_BuildType.cmake +index 17206f5..7a4f6a4 100644 +--- a/buildlib/RDMA_BuildType.cmake ++++ b/buildlib/RDMA_BuildType.cmake +@@ -39,4 +39,8 @@ function(RDMA_BuildType) + CACHE STRING "Default flags for RelWithDebInfo configuration" FORCE) + endif() + endforeach() ++ ++ if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo) ++ add_definitions("-DVERBS_DEBUG") ++ endif() + endfunction() +diff --git a/libibverbs/driver.h b/libibverbs/driver.h +index 926023b..bdb1aa4 100644 +--- a/libibverbs/driver.h ++++ b/libibverbs/driver.h +@@ -49,6 +49,56 @@ + + struct verbs_device; + ++enum { ++ VERBS_LOG_LEVEL_NONE, ++ VERBS_LOG_ERR, ++ VERBS_LOG_WARN, ++ VERBS_LOG_INFO, ++ VERBS_LOG_DEBUG, ++}; ++ ++void __verbs_log(struct verbs_context *ctx, uint32_t level, ++ const char *fmt, ...); ++ ++#define verbs_log(ctx, level, format, arg...) \ ++do { \ ++ int tmp = errno; \ ++ __verbs_log(ctx, level, "%s: %s:%d: " format, \ ++ (ctx)->context.device->name, __func__, __LINE__, ##arg); \ ++ errno = tmp; \ ++} while (0) ++ ++#define verbs_debug(ctx, format, arg...) \ ++ verbs_log(ctx, VERBS_LOG_DEBUG, format, ##arg) ++ ++#define verbs_info(ctx, format, arg...) \ ++ verbs_log(ctx, VERBS_LOG_INFO, format, ##arg) ++ ++#define verbs_warn(ctx, format, arg...) \ ++ verbs_log(ctx, VERBS_LOG_WARN, format, ##arg) ++ ++#define verbs_err(ctx, format, arg...) \ ++ verbs_log(ctx, VERBS_LOG_ERR, format, ##arg) ++ ++#ifdef VERBS_DEBUG ++#define verbs_log_datapath(ctx, level, format, arg...) \ ++ verbs_log(ctx, level, format, ##arg) ++#else ++#define verbs_log_datapath(ctx, level, format, arg...) {} ++#endif ++ ++#define verbs_debug_datapath(ctx, format, arg...) \ ++ verbs_log_datapath(ctx, VERBS_LOG_DEBUG, format, ##arg) ++ ++#define verbs_info_datapath(ctx, format, arg...) \ ++ verbs_log_datapath(ctx, VERBS_LOG_INFO, format, ##arg) ++ ++#define verbs_warn_datapath(ctx, format, arg...) \ ++ verbs_log_datapath(ctx, VERBS_LOG_WARN, format, ##arg) ++ ++#define verbs_err_datapath(ctx, format, arg...) \ ++ verbs_log_datapath(ctx, VERBS_LOG_ERR, format, ##arg) ++ + enum verbs_xrcd_mask { + VERBS_XRCD_HANDLE = 1 << 0, + VERBS_XRCD_RESERVED = 1 << 1 +diff --git a/libibverbs/init.c b/libibverbs/init.c +index f5340ea..52b166a 100644 +--- a/libibverbs/init.c ++++ b/libibverbs/init.c +@@ -36,6 +36,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -52,11 +53,30 @@ + #include + + #include ++#include "driver.h" + #include "ibverbs.h" + #include + + int abi_ver; + ++static uint32_t verbs_log_level; ++static FILE *verbs_log_fp; ++ ++__attribute__((format(printf, 3, 4))) ++void __verbs_log(struct verbs_context *ctx, uint32_t level, ++ const char *fmt, ...) ++{ ++ va_list args; ++ ++ if (level <= verbs_log_level) { ++ int tmp = errno; ++ va_start(args, fmt); ++ vfprintf(verbs_log_fp, fmt, args); ++ va_end(args); ++ errno = tmp; ++ } ++} ++ + struct ibv_driver { + struct list_node entry; + const struct verbs_device_ops *ops; +@@ -600,6 +620,49 @@ out: + return num_devices; + } + ++static void verbs_set_log_level(void) ++{ ++ char *env; ++ ++ env = getenv("VERBS_LOG_LEVEL"); ++ if (env) ++ verbs_log_level = strtol(env, NULL, 0); ++} ++ ++/* ++ * Fallback in case log file is not provided or can't be opened. ++ * Release mode: disable debug prints. ++ * Debug mode: Use stderr instead of a file. ++ */ ++static void verbs_log_file_fallback(void) ++{ ++#ifdef VERBS_DEBUG ++ verbs_log_fp = stderr; ++#else ++ verbs_log_level = VERBS_LOG_LEVEL_NONE; ++#endif ++} ++ ++static void verbs_set_log_file(void) ++{ ++ char *env; ++ ++ if (verbs_log_level == VERBS_LOG_LEVEL_NONE) ++ return; ++ ++ env = getenv("VERBS_LOG_FILE"); ++ if (!env) { ++ verbs_log_file_fallback(); ++ return; ++ } ++ ++ verbs_log_fp = fopen(env, "aw+"); ++ if (!verbs_log_fp) { ++ verbs_log_file_fallback(); ++ return; ++ } ++} ++ + int ibverbs_init(void) + { + char *env_value; +@@ -621,6 +684,8 @@ int ibverbs_init(void) + return -errno; + + check_memlock_limit(); ++ verbs_set_log_level(); ++ verbs_set_log_file(); + + return 0; + } +diff --git a/libibverbs/libibverbs.map.in b/libibverbs/libibverbs.map.in +index 7c0fb6a..905f58f 100644 +--- a/libibverbs/libibverbs.map.in ++++ b/libibverbs/libibverbs.map.in +@@ -167,6 +167,7 @@ IBVERBS_PRIVATE_@IBVERBS_PABI_VERSION@ { + global: + /* These historical symbols are now private to libibverbs */ + __ioctl_final_num_attrs; ++ __verbs_log; + _verbs_init_and_alloc_context; + execute_ioctl; + ibv_cmd_advise_mr; +-- +2.27.0 + diff --git a/0018-libhns-Use-the-verbs-logging-API-instead-of-printf-f.patch b/0018-libhns-Use-the-verbs-logging-API-instead-of-printf-f.patch new file mode 100644 index 0000000000000000000000000000000000000000..e53fb41fa6bad59c74f01d11f5bdc0017e2818f4 --- /dev/null +++ b/0018-libhns-Use-the-verbs-logging-API-instead-of-printf-f.patch @@ -0,0 +1,164 @@ +From 7c9a7a5848d19b792d1b108da55fa48611142a9b Mon Sep 17 00:00:00 2001 +From: Gal Pressman +Date: Tue, 29 Jun 2021 10:43:29 +0300 +Subject: libhns: Use the verbs logging API instead of printf/fprintf + +Use the generic verbs logging API instead of calling printf/fprintf +directly. +This means that by default the prints will no longer be seen, but can be +enabled by setting VERBS_LOG_LEVEL appropriately. + +Signed-off-by: Gal Pressman +--- + providers/hns/hns_roce_u_hw_v1.c | 34 +++++++++++++++++++++----------- + providers/hns/hns_roce_u_hw_v2.c | 4 ++-- + providers/hns/hns_roce_u_verbs.c | 6 ++++-- + 3 files changed, 28 insertions(+), 16 deletions(-) + +diff --git a/providers/hns/hns_roce_u_hw_v1.c b/providers/hns/hns_roce_u_hw_v1.c +index 279c9b0..6e107af 100644 +--- a/providers/hns/hns_roce_u_hw_v1.c ++++ b/providers/hns/hns_roce_u_hw_v1.c +@@ -108,7 +108,6 @@ static void hns_roce_update_cq_cons_index(struct hns_roce_context *ctx, + static void hns_roce_handle_error_cqe(struct hns_roce_cqe *cqe, + struct ibv_wc *wc) + { +- fprintf(stderr, PFX "error cqe!\n"); + switch (roce_get_field(cqe->cqe_byte_4, + CQE_BYTE_4_STATUS_OF_THE_OPERATION_M, + CQE_BYTE_4_STATUS_OF_THE_OPERATION_S) & +@@ -176,7 +175,9 @@ static struct hns_roce_cqe *next_cqe_sw(struct hns_roce_cq *cq) + static void *get_recv_wqe(struct hns_roce_qp *qp, int n) + { + if ((n < 0) || (n > qp->rq.wqe_cnt)) { +- printf("rq wqe index:%d,rq wqe cnt:%d\r\n", n, qp->rq.wqe_cnt); ++ verbs_err(verbs_get_ctx(qp->verbs_qp.qp.context), ++ "rq wqe index:%d,rq wqe cnt:%d\r\n", n, ++ qp->rq.wqe_cnt); + return NULL; + } + +@@ -186,7 +187,9 @@ static void *get_recv_wqe(struct hns_roce_qp *qp, int n) + static void *get_send_wqe(struct hns_roce_qp *qp, int n) + { + if ((n < 0) || (n > qp->sq.wqe_cnt)) { +- printf("sq wqe index:%d,sq wqe cnt:%d\r\n", n, qp->sq.wqe_cnt); ++ verbs_err(verbs_get_ctx(qp->verbs_qp.qp.context), ++ "sq wqe index:%d,sq wqe cnt:%d\r\n", n, ++ qp->sq.wqe_cnt); + return NULL; + } + +@@ -207,8 +210,9 @@ static int hns_roce_wq_overflow(struct hns_roce_wq *wq, int nreq, + cur = wq->head - wq->tail; + pthread_spin_unlock(&cq->lock); + +- printf("wq:(head = %d, tail = %d, max_post = %d), nreq = 0x%x\n", +- wq->head, wq->tail, wq->max_post, nreq); ++ verbs_err(verbs_get_ctx(cq->ibv_cq.context), ++ "wq:(head = %d, tail = %d, max_post = %d), nreq = 0x%x\n", ++ wq->head, wq->tail, wq->max_post, nreq); + + return cur + nreq >= wq->max_post; + } +@@ -221,7 +225,7 @@ static struct hns_roce_qp *hns_roce_find_qp(struct hns_roce_context *ctx, + if (ctx->qp_table[tind].refcnt) { + return ctx->qp_table[tind].table[qpn & ctx->qp_table_mask]; + } else { +- printf("hns_roce_find_qp fail!\n"); ++ verbs_err(&ctx->ibv_ctx, "hns_roce_find_qp fail!\n"); + return NULL; + } + } +@@ -273,7 +277,8 @@ static int hns_roce_v1_poll_one(struct hns_roce_cq *cq, + *cur_qp = hns_roce_find_qp(to_hr_ctx(cq->ibv_cq.context), + qpn & 0xffffff); + if (!*cur_qp) { +- fprintf(stderr, PFX "can't find qp!\n"); ++ verbs_err(verbs_get_ctx(cq->ibv_cq.context), ++ PFX "can't find qp!\n"); + return CQ_POLL_ERR; + } + } +@@ -312,6 +317,8 @@ static int hns_roce_v1_poll_one(struct hns_roce_cq *cq, + if (roce_get_field(cqe->cqe_byte_4, + CQE_BYTE_4_STATUS_OF_THE_OPERATION_M, + CQE_BYTE_4_STATUS_OF_THE_OPERATION_S) != HNS_ROCE_CQE_SUCCESS) { ++ verbs_err(verbs_get_ctx(cq->ibv_cq.context), ++ PFX "error cqe!\n"); + hns_roce_handle_error_cqe(cqe, wc); + return CQ_OK; + } +@@ -475,8 +482,9 @@ static int hns_roce_u_v1_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr, + if (wr->num_sge > qp->sq.max_gs) { + ret = -1; + *bad_wr = wr; +- printf("wr->num_sge(<=%d) = %d, check failed!\r\n", +- qp->sq.max_gs, wr->num_sge); ++ verbs_err(verbs_get_ctx(ibvqp->context), ++ "wr->num_sge(<=%d) = %d, check failed!\r\n", ++ qp->sq.max_gs, wr->num_sge); + goto out; + } + +@@ -544,8 +552,9 @@ static int hns_roce_u_v1_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr, + if (le32toh(ctrl->msg_length) > qp->max_inline_data) { + ret = -1; + *bad_wr = wr; +- printf("inline data len(1-32)=%d, send_flags = 0x%x, check failed!\r\n", +- wr->send_flags, ctrl->msg_length); ++ verbs_err(verbs_get_ctx(ibvqp->context), ++ "inline data len(1-32)=%d, send_flags = 0x%x, check failed!\r\n", ++ wr->send_flags, ctrl->msg_length); + return ret; + } + +@@ -650,7 +659,8 @@ static int hns_roce_u_v1_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, + + if (!ret && (attr_mask & IBV_QP_PORT)) { + hr_qp->port_num = attr->port_num; +- printf("hr_qp->port_num= 0x%x\n", hr_qp->port_num); ++ verbs_err(verbs_get_ctx(qp->context), "hr_qp->port_num= 0x%x\n", ++ hr_qp->port_num); + } + + hr_qp->sl = attr->ah_attr.sl; +diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c +index 4c21720..d4b76b5 100644 +--- a/providers/hns/hns_roce_u_hw_v2.c ++++ b/providers/hns/hns_roce_u_hw_v2.c +@@ -629,8 +629,8 @@ static int hns_roce_v2_poll_one(struct hns_roce_cq *cq, + + ret = hns_roce_handle_recv_inl_wqe(cqe, cur_qp, wc, opcode); + if (ret) { +- fprintf(stderr, +- PFX "failed to handle recv inline wqe!\n"); ++ verbs_err(verbs_get_ctx(cq->ibv_cq.context), ++ PFX "failed to handle recv inline wqe!\n"); + return ret; + } + +diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c +index 2a9e880..8840a9d 100644 +--- a/providers/hns/hns_roce_u_verbs.c ++++ b/providers/hns/hns_roce_u_verbs.c +@@ -164,12 +164,14 @@ struct ibv_mr *hns_roce_u_reg_mr(struct ibv_pd *pd, void *addr, size_t length, + struct ib_uverbs_reg_mr_resp resp; + + if (!addr) { +- fprintf(stderr, "2nd parm addr is NULL!\n"); ++ verbs_err(verbs_get_ctx(pd->context), ++ "2nd parm addr is NULL!\n"); + return NULL; + } + + if (!length) { +- fprintf(stderr, "3st parm length is 0!\n"); ++ verbs_err(verbs_get_ctx(pd->context), ++ "3st parm length is 0!\n"); + return NULL; + } + +-- +2.27.0 + diff --git a/0019-libhns-The-function-declaration-should-be-the-same-a.patch b/0019-libhns-The-function-declaration-should-be-the-same-a.patch new file mode 100644 index 0000000000000000000000000000000000000000..68c440a87233a7006fc3f24a898868750505fca6 --- /dev/null +++ b/0019-libhns-The-function-declaration-should-be-the-same-a.patch @@ -0,0 +1,34 @@ +From 4780e0a4c8cf2112425d04b939825a30603d87e6 Mon Sep 17 00:00:00 2001 +From: Xinhao Liu +Date: Tue, 9 Nov 2021 20:41:03 +0800 +Subject: libhns: The function declaration should be the same as the definition + +The parameter names should be the same when the function is declared and +defined. + +Signed-off-by: Xinhao Liu +Signed-off-by: Wenpeng Liang +Signed-off-by: Leon Romanovsky +--- + providers/hns/hns_roce_u.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/providers/hns/hns_roce_u.h b/providers/hns/hns_roce_u.h +index 21a5a6b..a5aa469 100644 +--- a/providers/hns/hns_roce_u.h ++++ b/providers/hns/hns_roce_u.h +@@ -372,9 +372,9 @@ int hns_roce_u_free_pd(struct ibv_pd *pd); + + struct ibv_mr *hns_roce_u_reg_mr(struct ibv_pd *pd, void *addr, size_t length, + uint64_t hca_va, int access); +-int hns_roce_u_rereg_mr(struct verbs_mr *mr, int flags, struct ibv_pd *pd, ++int hns_roce_u_rereg_mr(struct verbs_mr *vmr, int flags, struct ibv_pd *pd, + void *addr, size_t length, int access); +-int hns_roce_u_dereg_mr(struct verbs_mr *mr); ++int hns_roce_u_dereg_mr(struct verbs_mr *vmr); + + struct ibv_mw *hns_roce_u_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type); + int hns_roce_u_dealloc_mw(struct ibv_mw *mw); +-- +2.27.0 + diff --git a/0020-libhns-The-content-of-the-header-file-should-be-prot.patch b/0020-libhns-The-content-of-the-header-file-should-be-prot.patch new file mode 100644 index 0000000000000000000000000000000000000000..4b3d72ea1a22e8ce72040a058f9a8aa1cafe24aa --- /dev/null +++ b/0020-libhns-The-content-of-the-header-file-should-be-prot.patch @@ -0,0 +1,40 @@ +From 46c810472a1a6e3e093c21b6bcd43af0a0eda10b Mon Sep 17 00:00:00 2001 +From: Xinhao Liu +Date: Tue, 9 Nov 2021 20:41:02 +0800 +Subject: libhns: The content of the header file should be protected with + #define + +Header files should be protected with #define to prevent repeated +inclusion. + +Signed-off-by: Xinhao Liu +Signed-off-by: Wenpeng Liang +Signed-off-by: Leon Romanovsky +--- + providers/hns/hns_roce_u_db.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/providers/hns/hns_roce_u_db.h b/providers/hns/hns_roce_u_db.h +index 13df9b5..ca056c3 100644 +--- a/providers/hns/hns_roce_u_db.h ++++ b/providers/hns/hns_roce_u_db.h +@@ -29,14 +29,14 @@ + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ ++#ifndef _HNS_ROCE_U_DB_H ++#define _HNS_ROCE_U_DB_H + + #include + + #include + #include "hns_roce_u.h" + +-#ifndef _HNS_ROCE_U_DB_H +-#define _HNS_ROCE_U_DB_H + + #define HNS_ROCE_WORD_NUM 2 + +-- +2.27.0 + diff --git a/0021-libhns-Fix-wrong-type-of-variables-and-fields.patch b/0021-libhns-Fix-wrong-type-of-variables-and-fields.patch new file mode 100644 index 0000000000000000000000000000000000000000..c6bf051dbada36c4567b8024bc8dd8931b2e7d92 --- /dev/null +++ b/0021-libhns-Fix-wrong-type-of-variables-and-fields.patch @@ -0,0 +1,124 @@ +From dc29ea131407fbbe93497059b61e3ef22a675df1 Mon Sep 17 00:00:00 2001 +From: Xinhao Liu +Date: Tue, 9 Nov 2021 20:41:01 +0800 +Subject: libhns: Fix wrong type of variables and fields + +Some variables and fields should be in type of unsigned instead of signed. + +Signed-off-by: Xinhao Liu +Signed-off-by: Wenpeng Liang +Signed-off-by: Leon Romanovsky +--- + providers/hns/hns_roce_u.h | 6 +++--- + providers/hns/hns_roce_u_hw_v1.c | 6 +++--- + providers/hns/hns_roce_u_hw_v2.c | 11 +++++------ + 3 files changed, 11 insertions(+), 12 deletions(-) + +diff --git a/providers/hns/hns_roce_u.h b/providers/hns/hns_roce_u.h +index a5aa469..92dc26c 100644 +--- a/providers/hns/hns_roce_u.h ++++ b/providers/hns/hns_roce_u.h +@@ -101,7 +101,7 @@ + #define roce_set_bit(origin, shift, val) \ + roce_set_field((origin), (1ul << (shift)), (shift), (val)) + +-#define hr_ilog32(n) ilog32((n) - 1) ++#define hr_ilog32(n) ilog32((unsigned int)(n) - 1) + + enum { + HNS_ROCE_QP_TABLE_BITS = 8, +@@ -205,7 +205,7 @@ struct hns_roce_cq { + + struct hns_roce_idx_que { + struct hns_roce_buf buf; +- int entry_shift; ++ unsigned int entry_shift; + unsigned long *bitmap; + int bitmap_cnt; + unsigned int head; +@@ -252,7 +252,7 @@ struct hns_roce_sge_info { + struct hns_roce_sge_ex { + int offset; + unsigned int sge_cnt; +- int sge_shift; ++ unsigned int sge_shift; + }; + + struct hns_roce_rinl_sge { +diff --git a/providers/hns/hns_roce_u_hw_v1.c b/providers/hns/hns_roce_u_hw_v1.c +index 6e107af..838e004 100644 +--- a/providers/hns/hns_roce_u_hw_v1.c ++++ b/providers/hns/hns_roce_u_hw_v1.c +@@ -220,7 +220,7 @@ static int hns_roce_wq_overflow(struct hns_roce_wq *wq, int nreq, + static struct hns_roce_qp *hns_roce_find_qp(struct hns_roce_context *ctx, + uint32_t qpn) + { +- int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift; ++ uint32_t tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift; + + if (ctx->qp_table[tind].refcnt) { + return ctx->qp_table[tind].table[qpn & ctx->qp_table_mask]; +@@ -232,7 +232,7 @@ static struct hns_roce_qp *hns_roce_find_qp(struct hns_roce_context *ctx, + + static void hns_roce_clear_qp(struct hns_roce_context *ctx, uint32_t qpn) + { +- int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift; ++ uint32_t tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift; + + if (!--ctx->qp_table[tind].refcnt) + free(ctx->qp_table[tind].table); +@@ -740,7 +740,7 @@ static int hns_roce_u_v1_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr, + struct ibv_recv_wr **bad_wr) + { + int ret = 0; +- int nreq; ++ unsigned int nreq; + struct ibv_sge *sg; + struct hns_roce_rc_rq_wqe *rq_wqe; + struct hns_roce_qp *qp = to_hr_qp(ibvqp); +diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c +index d4b76b5..d0df51a 100644 +--- a/providers/hns/hns_roce_u_hw_v2.c ++++ b/providers/hns/hns_roce_u_hw_v2.c +@@ -248,7 +248,7 @@ static void *get_srq_wqe(struct hns_roce_srq *srq, unsigned int n) + return srq->wqe_buf.buf + (n << srq->wqe_shift); + } + +-static void *get_idx_buf(struct hns_roce_idx_que *idx_que, int n) ++static void *get_idx_buf(struct hns_roce_idx_que *idx_que, unsigned int n) + { + return idx_que->buf.buf + (n << idx_que->entry_shift); + } +@@ -352,7 +352,7 @@ static void hns_roce_v2_update_cq_cons_index(struct hns_roce_context *ctx, + static struct hns_roce_qp *hns_roce_v2_find_qp(struct hns_roce_context *ctx, + uint32_t qpn) + { +- int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift; ++ uint32_t tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift; + + if (ctx->qp_table[tind].refcnt) + return ctx->qp_table[tind].table[qpn & ctx->qp_table_mask]; +@@ -982,9 +982,8 @@ static int fill_ud_data_seg(struct hns_roce_ud_sq_wqe *ud_sq_wqe, + return ret; + } + +-static int set_ud_wqe(void *wqe, struct hns_roce_qp *qp, +- struct ibv_send_wr *wr, int nreq, +- struct hns_roce_sge_info *sge_info) ++static int set_ud_wqe(void *wqe, struct hns_roce_qp *qp, struct ibv_send_wr *wr, ++ unsigned int nreq, struct hns_roce_sge_info *sge_info) + { + struct hns_roce_ah *ah = to_hr_ah(wr->wr.ud.ah); + struct hns_roce_ud_sq_wqe *ud_sq_wqe = wqe; +@@ -1140,7 +1139,7 @@ static int check_rc_opcode(struct hns_roce_rc_sq_wqe *wqe, + } + + static int set_rc_wqe(void *wqe, struct hns_roce_qp *qp, struct ibv_send_wr *wr, +- int nreq, struct hns_roce_sge_info *sge_info) ++ unsigned int nreq, struct hns_roce_sge_info *sge_info) + { + struct hns_roce_rc_sq_wqe *rc_sq_wqe = wqe; + struct hns_roce_v2_wqe_data_seg *dseg; +-- +2.27.0 + diff --git a/0022-libhns-Fix-wrong-print-format-for-unsigned-type.patch b/0022-libhns-Fix-wrong-print-format-for-unsigned-type.patch new file mode 100644 index 0000000000000000000000000000000000000000..2188ab949a4b24c138b32c18d89d27408ab1f8dc --- /dev/null +++ b/0022-libhns-Fix-wrong-print-format-for-unsigned-type.patch @@ -0,0 +1,30 @@ +From 031ccf570369d820dab067cf29fb17e338cd4b28 Mon Sep 17 00:00:00 2001 +From: Xinhao Liu +Date: Tue, 9 Nov 2021 20:41:00 +0800 +Subject: libhns: Fix wrong print format for unsigned type + +Change %d printf fortmat to %u for unsigned int variant. + +Signed-off-by: Xinhao Liu +Signed-off-by: Wenpeng Liang +Signed-off-by: Leon Romanovsky +--- + providers/hns/hns_roce_u_verbs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c +index 8840a9d..923c005 100644 +--- a/providers/hns/hns_roce_u_verbs.c ++++ b/providers/hns/hns_roce_u_verbs.c +@@ -73,7 +73,7 @@ int hns_roce_u_query_device(struct ibv_context *context, + sub_minor = raw_fw_ver & 0xffff; + + snprintf(attr->orig_attr.fw_ver, sizeof(attr->orig_attr.fw_ver), +- "%d.%d.%03d", major, minor, sub_minor); ++ "%u.%u.%03u", major, minor, sub_minor); + + return 0; + } +-- +2.27.0 + diff --git a/0023-libhns-Remove-redundant-variable-initialization.patch b/0023-libhns-Remove-redundant-variable-initialization.patch new file mode 100644 index 0000000000000000000000000000000000000000..8391fad10b6a01c3610d28515e77e3aa0efc9667 --- /dev/null +++ b/0023-libhns-Remove-redundant-variable-initialization.patch @@ -0,0 +1,33 @@ +From e451dbaff5f0dd1715b6411169e970021cd43f4f Mon Sep 17 00:00:00 2001 +From: Yixing Liu +Date: Tue, 9 Nov 2021 20:40:59 +0800 +Subject: libhns: Remove redundant variable initialization + +The variable of owner_bit has been assigned before the reference, so there +is no need to initialize. + +Signed-off-by: Yixing Liu +Signed-off-by: Wenpeng Liang +Signed-off-by: Leon Romanovsky +--- + providers/hns/hns_roce_u_hw_v2.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c +index d0df51a..5fb6477 100644 +--- a/providers/hns/hns_roce_u_hw_v2.c ++++ b/providers/hns/hns_roce_u_hw_v2.c +@@ -1399,9 +1399,9 @@ static void __hns_roce_v2_cq_clean(struct hns_roce_cq *cq, uint32_t qpn, + { + int nfreed = 0; + bool is_recv_cqe; ++ uint8_t owner_bit; + uint16_t wqe_index; + uint32_t prod_index; +- uint8_t owner_bit = 0; + struct hns_roce_v2_cqe *cqe, *dest; + struct hns_roce_context *ctx = to_hr_ctx(cq->ibv_cq.context); + +-- +2.27.0 + diff --git a/0024-libhns-Remove-unused-macros.patch b/0024-libhns-Remove-unused-macros.patch new file mode 100644 index 0000000000000000000000000000000000000000..875ccec9eb582c35baeb3a72a2af9746666df1fb --- /dev/null +++ b/0024-libhns-Remove-unused-macros.patch @@ -0,0 +1,33 @@ +From 21d81f659d801230a1ccf1aadf9b1ecba5a3ccd8 Mon Sep 17 00:00:00 2001 +From: Lang Cheng +Date: Tue, 9 Nov 2021 20:40:57 +0800 +Subject: libhns: Remove unused macros + +These macros used to work, but are no longer used, they should be removed. + +Fixes: 516b8d4e4ebe ("providers: Use the new match_device and allocate_device ops") +Fixes: 887b78c80224 ("libhns: Add initial main frame") +Signed-off-by: Lang Cheng +Signed-off-by: Wenpeng Liang +Signed-off-by: Leon Romanovsky +--- + providers/hns/hns_roce_u.c | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/providers/hns/hns_roce_u.c b/providers/hns/hns_roce_u.c +index 3b31ad3..9dc4905 100644 +--- a/providers/hns/hns_roce_u.c ++++ b/providers/hns/hns_roce_u.c +@@ -41,9 +41,6 @@ + + static void hns_roce_free_context(struct ibv_context *ibctx); + +-#define HID_LEN 15 +-#define DEV_MATCH_LEN 128 +- + #ifndef PCI_VENDOR_ID_HUAWEI + #define PCI_VENDOR_ID_HUAWEI 0x19E5 + #endif +-- +2.27.0 + diff --git a/rdma-core.spec b/rdma-core.spec index 436a5067f6b5de3ccee218278d80330646e55d88..a70578d164aa48d3747c4cf26213509dd6e009b8 100644 --- a/rdma-core.spec +++ b/rdma-core.spec @@ -1,6 +1,6 @@ Name: rdma-core Version: 35.1 -Release: 3 +Release: 4 Summary: RDMA core userspace libraries and daemons License: GPLv2 or BSD Url: https://github.com/linux-rdma/rdma-core @@ -23,6 +23,14 @@ Patch13: 0013-libhns-Refactor-the-process-of-create_srq.patch Patch14: 0014-libhns-Remove-the-reserved-wqe-of-SRQ.patch Patch15: 0015-libhns-Refactor-process-of-setting-extended-sge.patch Patch16: 0016-libhns-Optimize-set_sge-process.patch +Patch17: 0017-verbs-Add-generic-logging-API.patch +Patch18: 0018-libhns-Use-the-verbs-logging-API-instead-of-printf-f.patch +Patch19: 0019-libhns-The-function-declaration-should-be-the-same-a.patch +Patch20: 0020-libhns-The-content-of-the-header-file-should-be-prot.patch +Patch21: 0021-libhns-Fix-wrong-type-of-variables-and-fields.patch +Patch22: 0022-libhns-Fix-wrong-print-format-for-unsigned-type.patch +Patch23: 0023-libhns-Remove-redundant-variable-initialization.patch +Patch24: 0024-libhns-Remove-unused-macros.patch BuildRequires: binutils cmake >= 2.8.11 gcc libudev-devel pkgconfig pkgconfig(libnl-3.0) BuildRequires: pkgconfig(libnl-route-3.0) valgrind-devel systemd systemd-devel @@ -267,6 +275,12 @@ fi %{_mandir}/* %changelog +* Wed Aug 03 2022 luozhengfeng - 35.1-4 +- Type: enhancement +- ID: NA +- SUG: NA +- DESC: Adding logging API and cleanup for hns + * Mon Jul 11 2022 luozhengfeng - 35.1-3 - Type: bugfix - ID: NA