[PATCH RFC v2 08/10] IB/mlx5: Support IB_WR_REG_SIG_MR
This patch implements IB_WR_REG_SIG_MR posted by the user. Baisically this WR involvs 3 WQEs in order to prepare and properly register the signature layout: 1. post UMR WR to register the sig_mr in one of two possible ways: * In case the user registered a single MR for data so the UMR data segment consists of: - single klm (data MR) passed by the user - BSF with signature attributes requested by the user. * In case the user registered 2 MRs, one for data and one for protection, the UMR consists of: - strided block format which includes data and protection MRs and their repetitive block format. - BSF with signature attributes requested by the user. 2. post SET_PSV in order to set the for the memory domain initial signature parameters passed by the user. 3. post SET_PSV in order to set the for the wire domain initial signature parameters passed by the user. This patch also introduces some helper functions to set the BSF correctly and determining the signature format selectors. Signed-off-by: Sagi Grimberg sa...@mellanox.com --- drivers/infiniband/hw/mlx5/qp.c | 416 +++ include/linux/mlx5/qp.h | 56 ++ 2 files changed, 472 insertions(+), 0 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index ca78078..37e3715 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c @@ -1719,6 +1719,26 @@ static __be64 frwr_mkey_mask(void) return cpu_to_be64(result); } +static __be64 sig_mkey_mask(void) +{ + u64 result; + + result = MLX5_MKEY_MASK_LEN | + MLX5_MKEY_MASK_PAGE_SIZE| + MLX5_MKEY_MASK_START_ADDR | + MLX5_MKEY_MASK_EN_RINVAL| + MLX5_MKEY_MASK_KEY | + MLX5_MKEY_MASK_LR | + MLX5_MKEY_MASK_LW | + MLX5_MKEY_MASK_RR | + MLX5_MKEY_MASK_RW | + MLX5_MKEY_MASK_SMALL_FENCE | + MLX5_MKEY_MASK_FREE | + MLX5_MKEY_MASK_BSF_EN; + + return cpu_to_be64(result); +} + static void set_frwr_umr_segment(struct mlx5_wqe_umr_ctrl_seg *umr, struct ib_send_wr *wr, int li) { @@ -1901,6 +1921,339 @@ static int set_data_inl_seg(struct mlx5_ib_qp *qp, struct ib_send_wr *wr, return 0; } +static u16 prot_field_size(enum ib_signature_type type, u16 block_size) +{ + switch (type) { + case IB_SIG_TYPE_T10_DIF: + return MLX5_DIF_SIZE; + default: + return 0; + } +} + +static u8 bs_selector(int block_size) +{ + switch (block_size) { + case 512: return 0x1; + case 520: return 0x2; + case 4096: return 0x3; + case 4160: return 0x4; + case 1073741824:return 0x5; + default:return 0; + } +} + +static int format_selector(struct ib_sig_attrs *attr, + struct ib_sig_domain *domain, + int *selector) +{ + +#define FORMAT_DIF_NONE0 +#define FORMAT_DIF_CRC_INC 4 +#define FORMAT_DIF_CSUM_INC12 +#define FORMAT_DIF_CRC_NO_INC 13 +#define FORMAT_DIF_CSUM_NO_INC 14 + + switch (domain-sig.dif.type) { + case IB_T10DIF_NONE: + /* No DIF */ + *selector = FORMAT_DIF_NONE; + break; + case IB_T10DIF_TYPE1: /* Fall through */ + case IB_T10DIF_TYPE2: + switch (domain-sig.dif.bg_type) { + case IB_T10DIF_CRC: + *selector = FORMAT_DIF_CRC_INC; + break; + case IB_T10DIF_CSUM: + *selector = FORMAT_DIF_CSUM_INC; + break; + default: + return 1; + } + break; + case IB_T10DIF_TYPE3: + switch (domain-sig.dif.bg_type) { + case IB_T10DIF_CRC: + *selector = domain-sig.dif.type3_inc_reftag ? + FORMAT_DIF_CRC_INC : + FORMAT_DIF_CRC_NO_INC; + break; + case IB_T10DIF_CSUM: + *selector = domain-sig.dif.type3_inc_reftag ? + FORMAT_DIF_CSUM_INC : + FORMAT_DIF_CSUM_NO_INC; + break; + default: + return 1; + } + break; + default: + return 1; + } + + return 0; +} + +static int mlx5_set_bsf(struct ib_mr *sig_mr, + struct ib_sig_attrs *sig_attrs, + struct mlx5_bsf
[PATCH RFC v2 02/10] IB/core: Introduce Signature Verbs API
This commit Introduces the Verbs Interface for signature related operations. A signature handover operation shall configure the layouts of data and protection attributes both in memory and wire domains. Signature operations are: - INSERT Generate and insert protection information when handing over data from input space to output space. - vaildate and STRIP: Validate protection information and remove it when handing over data from input space to output space. - validate and PASS: Validate protection information and pass it when handing over data from input space to output space. Once the signature handover opration is done, the HCA will offload data integrity generation/validation while performing the actual data transfer. Additions: 1. HCA signature capabilities in device attributes Verbs provider supporting Signature handover operations shall fill relevant fields in device attributes structure returned by ib_query_device. 2. QP creation flag IB_QP_CREATE_SIGNATURE_EN Creating QP that will carry signature handover operations may require some special preperations from the verbs provider. So we add QP creation flag IB_QP_CREATE_SIGNATURE_EN to declare that the created QP may carry out signature handover operations. Expose signature support to verbs layer (no support for now) 3. New send work request IB_WR_REG_SIG_MR Signature handover work request. This WR will define the signature handover properties of the memory/wire domains as well as the domains layout. The purpose of this work request is to bind all the needed information for the signature operation: - data to be transferred: wr-sg_list. * The raw data, pre-registered to a single MR (normally, before signature, this MR would have been used directly for the data transfer). the user will pass the data sge via sg_list exsisting member. - data protection guards: sig_handover.prot. * The data protection buffer, pre-registered to a single MR, which contains the data integrity guards of the raw data blocks. Note that it may not always exist, only in cases where the user is interested in storing protection guards in memory. - signature operation attributes: sig_handover.sig_attrs. * Tells the HCA how to validate/generate the protection information. Once the work request is executed, the memory region which will describe the signature transaction will be the sig_mr. The application can now go ahead and send the sig_mr.rkey or use the sig_mr.lkey for data transfer. 4. New Verb ib_check_sig_status check_sig_status Verb shall check if any signature errors are pending for a specific signature-enabled ib_mr. This Verb is a lightwight check and is allowed to be taken from interrupt context. Application must call this verb after it is known that the actual data transfer has finished. Signed-off-by: Sagi Grimberg sa...@mellanox.com --- drivers/infiniband/core/verbs.c |8 +++ include/rdma/ib_verbs.h | 127 ++- 2 files changed, 134 insertions(+), 1 deletions(-) diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index 1d94a5c..5636d65 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -1293,3 +1293,11 @@ int ib_dealloc_xrcd(struct ib_xrcd *xrcd) return xrcd-device-dealloc_xrcd(xrcd); } EXPORT_SYMBOL(ib_dealloc_xrcd); + +int ib_check_sig_status(struct ib_mr *sig_mr, + struct ib_sig_err *sig_err) +{ + return sig_mr-device-check_sig_status ? + sig_mr-device-check_sig_status(sig_mr, sig_err) : -ENOSYS; +} +EXPORT_SYMBOL(ib_check_sig_status); diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 53f065d..19b37eb 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -116,7 +116,19 @@ enum ib_device_cap_flags { IB_DEVICE_MEM_MGT_EXTENSIONS= (121), IB_DEVICE_BLOCK_MULTICAST_LOOPBACK = (122), IB_DEVICE_MEM_WINDOW_TYPE_2A= (123), - IB_DEVICE_MEM_WINDOW_TYPE_2B= (124) + IB_DEVICE_MEM_WINDOW_TYPE_2B= (124), + IB_DEVICE_SIGNATURE_HANDOVER= (125), +}; + +enum ib_signature_prot_cap { + IB_PROT_T10DIF_TYPE_1 = 1, + IB_PROT_T10DIF_TYPE_2 = 1 1, + IB_PROT_T10DIF_TYPE_3 = 1 2, +}; + +enum ib_signature_guard_cap { + IB_GUARD_T10DIF_CRC = 1, + IB_GUARD_T10DIF_CSUM= 1 1, }; enum ib_atomic_cap { @@ -166,6 +178,8 @@ struct ib_device_attr { unsigned intmax_fast_reg_page_list_len; u16 max_pkeys; u8 local_ca_ack_delay; + int sig_prot_cap; + int sig_guard_cap; }; enum ib_mtu { @@ -630,6 +644,7 @@ enum ib_qp_type { enum ib_qp_create_flags { IB_QP_CREATE_IPOIB_UD_LSO =
[PATCH RFC v2 06/10] IB/mlx5: remove MTT access mode from umr flags helper function
get_umr_flags helper function might be used for types of access modes other than ACCESS_MODE_MTT, such as ACCESS_MODE_KLM. so remove it from helper and caller will add it's own access mode flag. This commit does not add/change functionality. Signed-off-by: Sagi Grimberg sa...@mellanox.com --- drivers/infiniband/hw/mlx5/qp.c |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index dc8d9fc..ca78078 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c @@ -1773,7 +1773,7 @@ static u8 get_umr_flags(int acc) (acc IB_ACCESS_REMOTE_WRITE ? MLX5_PERM_REMOTE_WRITE : 0) | (acc IB_ACCESS_REMOTE_READ ? MLX5_PERM_REMOTE_READ : 0) | (acc IB_ACCESS_LOCAL_WRITE ? MLX5_PERM_LOCAL_WRITE : 0) | - MLX5_PERM_LOCAL_READ | MLX5_PERM_UMR_EN | MLX5_ACCESS_MODE_MTT; + MLX5_PERM_LOCAL_READ | MLX5_PERM_UMR_EN; } static void set_mkey_segment(struct mlx5_mkey_seg *seg, struct ib_send_wr *wr, @@ -1785,7 +1785,8 @@ static void set_mkey_segment(struct mlx5_mkey_seg *seg, struct ib_send_wr *wr, return; } - seg-flags = get_umr_flags(wr-wr.fast_reg.access_flags); + seg-flags = get_umr_flags(wr-wr.fast_reg.access_flags) | +MLX5_ACCESS_MODE_MTT; *writ = seg-flags (MLX5_PERM_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE); seg-qpn_mkey7_0 = cpu_to_be32((wr-wr.fast_reg.rkey 0xff) | 0xff00); seg-flags_pd = cpu_to_be32(MLX5_MKEY_REMOTE_INVAL); -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC v2 10/10] IB/mlx5: Publish support in signature feature
Currently support only T10-DIF types of signature handover operations (typs 1|2|3). Signed-off-by: Sagi Grimberg sa...@mellanox.com --- drivers/infiniband/hw/mlx5/main.c |9 + 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index f3c7111..3dd8219 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -274,6 +274,15 @@ static int mlx5_ib_query_device(struct ib_device *ibdev, if (flags MLX5_DEV_CAP_FLAG_XRC) props-device_cap_flags |= IB_DEVICE_XRC; props-device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS; + if (flags MLX5_DEV_CAP_FLAG_SIG_HAND_OVER) { + props-device_cap_flags |= IB_DEVICE_SIGNATURE_HANDOVER; + /* At this stage no support for signature handover */ + props-sig_prot_cap = IB_PROT_T10DIF_TYPE_1 | + IB_PROT_T10DIF_TYPE_2 | + IB_PROT_T10DIF_TYPE_3; + props-sig_guard_cap = IB_GUARD_T10DIF_CRC | + IB_GUARD_T10DIF_CSUM; + } props-vendor_id = be32_to_cpup((__be32 *)(out_mad-data + 36)) 0xff; -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC v2 04/10] IB/mlx5: Initialize mlx5_ib_qp signature related
If user requested signature enable we Initialize relevant mlx5_ib_qp members. we mark the qp as sig_enable we initiatlize empty sig_err_list, and we increase qp size. Signed-off-by: Sagi Grimberg sa...@mellanox.com --- drivers/infiniband/hw/mlx5/mlx5_ib.h |3 +++ drivers/infiniband/hw/mlx5/qp.c |5 + include/linux/mlx5/qp.h |1 + 3 files changed, 9 insertions(+), 0 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h index 45d7424..758f0e1 100644 --- a/drivers/infiniband/hw/mlx5/mlx5_ib.h +++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h @@ -189,6 +189,9 @@ struct mlx5_ib_qp { int create_type; u32 pa_lkey; + + /* Store signature errors */ + boolsignature_en; }; struct mlx5_ib_cq_buf { diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index 045f8cd..c80122e 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c @@ -734,6 +734,11 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd, spin_lock_init(qp-sq.lock); spin_lock_init(qp-rq.lock); + if (init_attr-create_flags == IB_QP_CREATE_SIGNATURE_EN) { + init_attr-cap.max_send_wr *= MLX5_SIGNATURE_SQ_MULT; + qp-signature_en = true; + } + if (init_attr-sq_sig_type == IB_SIGNAL_ALL_WR) qp-sq_signal_bits = MLX5_WQE_CTRL_CQ_UPDATE; diff --git a/include/linux/mlx5/qp.h b/include/linux/mlx5/qp.h index d9e3eac..174805c 100644 --- a/include/linux/mlx5/qp.h +++ b/include/linux/mlx5/qp.h @@ -37,6 +37,7 @@ #include linux/mlx5/driver.h #define MLX5_INVALID_LKEY 0x100 +#define MLX5_SIGNATURE_SQ_MULT 3 enum mlx5_qp_optpar { MLX5_QP_OPTPAR_ALT_ADDR_PATH= 1 0, -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC v2 05/10] IB/mlx5: Break wqe handling to begin finish routines
As a preliminary step for signature feature which will reuqire posting multiple (3) WQEs for a single WR, we break post_send routine WQE indexing into begin and finish routines. This patch does not change any functionality. Signed-off-by: Sagi Grimberg sa...@mellanox.com --- drivers/infiniband/hw/mlx5/qp.c | 95 --- 1 files changed, 59 insertions(+), 36 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index c80122e..dc8d9fc 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c @@ -1983,6 +1983,57 @@ static u8 get_fence(u8 fence, struct ib_send_wr *wr) } } +static int begin_wqe(struct mlx5_ib_qp *qp, void **seg, +struct mlx5_wqe_ctrl_seg **ctrl, +struct ib_send_wr *wr, int *idx, +int *size, int nreq) +{ + int err = 0; + if (unlikely(mlx5_wq_overflow(qp-sq, nreq, qp-ibqp.send_cq))) { + err = -ENOMEM; + return err; + } + + *idx = qp-sq.cur_post (qp-sq.wqe_cnt - 1); + *seg = mlx5_get_send_wqe(qp, *idx); + *ctrl = *seg; + *(uint32_t *)(*seg + 8) = 0; + (*ctrl)-imm = send_ieth(wr); + (*ctrl)-fm_ce_se = qp-sq_signal_bits | + (wr-send_flags IB_SEND_SIGNALED ? +MLX5_WQE_CTRL_CQ_UPDATE : 0) | + (wr-send_flags IB_SEND_SOLICITED ? +MLX5_WQE_CTRL_SOLICITED : 0); + + *seg += sizeof(**ctrl); + *size = sizeof(**ctrl) / 16; + + return err; +} + +static void finish_wqe(struct mlx5_ib_qp *qp, + struct mlx5_wqe_ctrl_seg *ctrl, + u8 size, unsigned idx, u64 wr_id, + int *nreq, u8 fence, u8 next_fence, + u32 mlx5_opcode) +{ + u8 opmod = 0; + ctrl-opmod_idx_opcode = cpu_to_be32(((u32)(qp-sq.cur_post) 8) | +mlx5_opcode | ((u32)opmod 24)); + ctrl-qpn_ds = cpu_to_be32(size | (qp-mqp.qpn 8)); + ctrl-fm_ce_se |= fence; + qp-fm_cache = next_fence; + if (unlikely(qp-wq_sig)) + ctrl-signature = wq_sig(ctrl); + + qp-sq.wrid[idx] = wr_id; + qp-sq.w_list[idx].opcode = mlx5_opcode; + qp-sq.wqe_head[idx] = qp-sq.head + (*nreq)++; + qp-sq.cur_post += DIV_ROUND_UP(size * 16, MLX5_SEND_WQE_BB); + qp-sq.w_list[idx].next = qp-sq.cur_post; +} + + int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, struct ib_send_wr **bad_wr) { @@ -1996,7 +2047,6 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, int uninitialized_var(size); void *qend = qp-sq.qend; unsigned long flags; - u32 mlx5_opcode; unsigned idx; int err = 0; int inl = 0; @@ -2005,7 +2055,6 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, int nreq; int i; u8 next_fence = 0; - u8 opmod = 0; u8 fence; spin_lock_irqsave(qp-sq.lock, flags); @@ -2018,36 +2067,23 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, goto out; } - if (unlikely(mlx5_wq_overflow(qp-sq, nreq, qp-ibqp.send_cq))) { + fence = qp-fm_cache; + num_sge = wr-num_sge; + if (unlikely(num_sge qp-sq.max_gs)) { mlx5_ib_warn(dev, \n); err = -ENOMEM; *bad_wr = wr; goto out; } - fence = qp-fm_cache; - num_sge = wr-num_sge; - if (unlikely(num_sge qp-sq.max_gs)) { + err = begin_wqe(qp, seg, ctrl, wr, idx, size, nreq); + if (err) { mlx5_ib_warn(dev, \n); err = -ENOMEM; *bad_wr = wr; goto out; } - idx = qp-sq.cur_post (qp-sq.wqe_cnt - 1); - seg = mlx5_get_send_wqe(qp, idx); - ctrl = seg; - *(uint32_t *)(seg + 8) = 0; - ctrl-imm = send_ieth(wr); - ctrl-fm_ce_se = qp-sq_signal_bits | - (wr-send_flags IB_SEND_SIGNALED ? -MLX5_WQE_CTRL_CQ_UPDATE : 0) | - (wr-send_flags IB_SEND_SOLICITED ? -MLX5_WQE_CTRL_SOLICITED : 0); - - seg += sizeof(*ctrl); - size = sizeof(*ctrl) / 16; - switch (ibqp-qp_type) { case IB_QPT_XRC_INI: xrc = seg; @@ -2197,22 +2233,9 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, } } - mlx5_opcode = mlx5_ib_opcode[wr-opcode]; - ctrl-opmod_idx_opcode =
[PATCH RFC v2 07/10] IB/mlx5: Keep mlx5 MRs in a radix tree under device
This will be useful when processing signature errors on a specific key. The mlx5 driver will lookup the matching mlx5 memory region structure and mark it as dirty (contains signature errors). Signed-off-by: Sagi Grimberg sa...@mellanox.com --- drivers/net/ethernet/mellanox/mlx5/core/main.c |1 + drivers/net/ethernet/mellanox/mlx5/core/mr.c | 20 include/linux/mlx5/driver.h| 12 3 files changed, 33 insertions(+), 0 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index b47739b..5b7b3c7 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -428,6 +428,7 @@ int mlx5_dev_init(struct mlx5_core_dev *dev, struct pci_dev *pdev) mlx5_init_cq_table(dev); mlx5_init_qp_table(dev); mlx5_init_srq_table(dev); + mlx5_init_mr_table(dev); return 0; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mr.c b/drivers/net/ethernet/mellanox/mlx5/core/mr.c index 2ade604..f72e0b6 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/mr.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/mr.c @@ -36,9 +36,18 @@ #include linux/mlx5/cmd.h #include mlx5_core.h +void mlx5_init_mr_table(struct mlx5_core_dev *dev) +{ + struct mlx5_mr_table *table = dev-priv.mr_table; + + rwlock_init(table-lock); + INIT_RADIX_TREE(table-tree, GFP_ATOMIC); +} + int mlx5_core_create_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr, struct mlx5_create_mkey_mbox_in *in, int inlen) { + struct mlx5_mr_table *table = dev-priv.mr_table; struct mlx5_create_mkey_mbox_out out; int err; u8 key; @@ -63,14 +72,21 @@ int mlx5_core_create_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr, mr-key = mlx5_idx_to_mkey(be32_to_cpu(out.mkey) 0xff) | key; mlx5_core_dbg(dev, out 0x%x, key 0x%x, mkey 0x%x\n, be32_to_cpu(out.mkey), key, mr-key); + /* connect to MR tree */ + write_lock_irq(table-lock); + err = radix_tree_insert(table-tree, mr-key 0xff00, mr); + write_unlock_irq(table-lock); + return err; } EXPORT_SYMBOL(mlx5_core_create_mkey); int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr) { + struct mlx5_mr_table *table = dev-priv.mr_table; struct mlx5_destroy_mkey_mbox_in in; struct mlx5_destroy_mkey_mbox_out out; + unsigned long flags; int err; memset(in, 0, sizeof(in)); @@ -85,6 +101,10 @@ int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr) if (out.hdr.status) return mlx5_cmd_status_to_err(out.hdr); + write_lock_irqsave(table-lock, flags); + radix_tree_delete(table-tree, mr-key 0xff00); + write_unlock_irqrestore(table-lock, flags); + return err; } EXPORT_SYMBOL(mlx5_core_destroy_mkey); diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h index 7c33487..5fe0690 100644 --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h @@ -488,6 +488,13 @@ struct mlx5_srq_table { struct radix_tree_root tree; }; +struct mlx5_mr_table { + /* protect radix tree +*/ + rwlock_tlock; + struct radix_tree_root tree; +}; + struct mlx5_priv { charname[MLX5_MAX_NAME_LEN]; struct mlx5_eq_tableeq_table; @@ -516,6 +523,10 @@ struct mlx5_priv { struct mlx5_cq_tablecq_table; /* end: cq staff */ + /* start: mr staff */ + struct mlx5_mr_tablemr_table; + /* end: mr staff */ + /* start: alloc staff */ struct mutexpgdir_mutex; struct list_headpgdir_list; @@ -691,6 +702,7 @@ int mlx5_core_query_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq, struct mlx5_query_srq_mbox_out *out); int mlx5_core_arm_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq, u16 lwm, int is_srq); +void mlx5_init_mr_table(struct mlx5_core_dev *dev); int mlx5_core_create_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr, struct mlx5_create_mkey_mbox_in *in, int inlen); int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr); -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC v2 00/10] Introduce Signature feature
This patchset Introduces Verbs level support for signature handover feature. Siganture is intended to implement end-to-end data integrity on a transactional basis in a completely offloaded manner. There are several end-to-end data integrity methods used today in various applications and/or upper layer protocols such as T10-DIF defined by SCSI specifications (SBC), CRC32, XOR8 and more. This patchset adds verbs support only for T10-DIF. The proposed framework allows adding more signature methods in the future. In T10-DIF, when a series of 512-byte data blocks are transferred, each block is followed by an 8-byte guard. The guard consists of CRC that protects the integrity of the data in the block, and some other tags that protects against mis-directed IOs. Data can be protected when transferred over the wire, but can also be protected in the memory of the sender/receiver. This allows true end- to-end protection against bits flipping either over the wire, through gateways, in memory, over PCI, etc. While T10-DIF clearly defines that over the wire protection guards are interleaved into the data stream (each 512-Byte block followed by 8-byte guard), when in memory, the protection guards may reside in a buffer separated from the data. Depending on the application, it is usually easier to handle the data when it is contiguous. In this case the data buffer will be of size 512xN and the protection buffer will be of size 8xN (where N is the number of blocks in the transaction). There are 3 kinds of signature handover operation: 1. Take unprotected data (from wire or memory) and ADD protection guards. 2. Take protetected data (from wire or memory), validate the data integrity against the protection guards and STRIP the protection guards. 3. Take protected data (from wire or memory), validate the data integrity against the protection guards and PASS the data with the guards as-is. This translates to defining to the HCA how/if data protection exists in memory domain, and how/if data protection exists is wire domain. The way that data integrity is performed is by using a new kind of memory region: signature-enabled MR, and a new kind of work request: REG_SIG_MR. The REG_SIG_MR WR operates on the signature-enabled MR, and defines all the needed information for the signature handover (data buffer, protection buffer if needed and signature attributes). The result is an MR that can be used for data transfer as usual, that will also add/validate/strip/pass protection guards. When the data transfer is successfully completed, it does not mean that there are no integrity errors. The user must afterwards check the signature status of the handover operation using a new light-weight verb. This feature shall be used in storage upper layer protocols iSER/SRP implementing end-to-end data integrity T10-DIF. Following this patchset, we will soon submit krping patches which will demonstrate the usage of these signature verbs. Patchset summary: - Intoduce verbs for create/destroy memory regions supporting signature. - Introduce IB core signature verbs API. - Implement mr create/destroy verbs in mlx5 driver. - Preperation patches for signature support in mlx5 driver. - Implement signature handover work request in mlx5 driver. - Implement signature error collection and handling in mlx5 driver. Changes from v1: - IB/core: Reduced sizeof ib_send_wr by using wr-sg_list for data and dedicated ib_sge for protection guards buffer. Currently sig_handover extension does not increase sizeof ib_send_wr - IB/core: Change enum to int for container variables. - IB/mlx5: Validate wr-num_sge=1 for REG_SIG_MR work request. Changes from v0: - Commit messages: Added more detailed explanation for signature work request. - IB/core: Remove indirect memory registration enablement from create_mr. Keep only signature enablement. - IB/mlx5: Changed signature error processing via MR radix lookup. Sagi Grimberg (10): IB/core: Introduce protected memory regions IB/core: Introduce Signature Verbs API IB/mlx5, mlx5_core: Support for create_mr and destroy_mr IB/mlx5: Initialize mlx5_ib_qp signature related IB/mlx5: Break wqe handling to begin finish routines IB/mlx5: remove MTT access mode from umr flags helper function IB/mlx5: Keep mlx5 MRs in a radix tree under device IB/mlx5: Support IB_WR_REG_SIG_MR IB/mlx5: Collect signature error completion IB/mlx5: Publish support in signature feature drivers/infiniband/core/verbs.c| 47 +++ drivers/infiniband/hw/mlx5/cq.c| 53 +++ drivers/infiniband/hw/mlx5/main.c | 12 + drivers/infiniband/hw/mlx5/mlx5_ib.h | 14 + drivers/infiniband/hw/mlx5/mr.c| 138 +++ drivers/infiniband/hw/mlx5/qp.c| 525 ++-- drivers/net/ethernet/mellanox/mlx5/core/main.c |1 + drivers/net/ethernet/mellanox/mlx5/core/mr.c | 84
[PATCH RFC v2 03/10] IB/mlx5, mlx5_core: Support for create_mr and destroy_mr
Support create_mr and destroy_mr verbs. Creating ib_mr may be done for either ib_mr that will register regular page lists like alloc_fast_reg_mr routine, or indirect ib_mr's that can register other (pre-registered) ib_mr's in an indirect manner. In addition user may request signature enable, that will mean that the created ib_mr may be attached with signature attributes (BSF, PSVs). Currently we only allow direct/indirect registration modes. Signed-off-by: Sagi Grimberg sa...@mellanox.com --- drivers/infiniband/hw/mlx5/main.c|2 + drivers/infiniband/hw/mlx5/mlx5_ib.h |4 + drivers/infiniband/hw/mlx5/mr.c | 109 ++ drivers/net/ethernet/mellanox/mlx5/core/mr.c | 64 +++ include/linux/mlx5/device.h | 25 ++ include/linux/mlx5/driver.h | 19 + 6 files changed, 223 insertions(+), 0 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 3f831de..2e67a37 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -1401,9 +1401,11 @@ static int init_one(struct pci_dev *pdev, dev-ib_dev.get_dma_mr = mlx5_ib_get_dma_mr; dev-ib_dev.reg_user_mr = mlx5_ib_reg_user_mr; dev-ib_dev.dereg_mr= mlx5_ib_dereg_mr; + dev-ib_dev.destroy_mr = mlx5_ib_destroy_mr; dev-ib_dev.attach_mcast= mlx5_ib_mcg_attach; dev-ib_dev.detach_mcast= mlx5_ib_mcg_detach; dev-ib_dev.process_mad = mlx5_ib_process_mad; + dev-ib_dev.create_mr = mlx5_ib_create_mr; dev-ib_dev.alloc_fast_reg_mr = mlx5_ib_alloc_fast_reg_mr; dev-ib_dev.alloc_fast_reg_page_list = mlx5_ib_alloc_fast_reg_page_list; dev-ib_dev.free_fast_reg_page_list = mlx5_ib_free_fast_reg_page_list; diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h index 836be91..45d7424 100644 --- a/drivers/infiniband/hw/mlx5/mlx5_ib.h +++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h @@ -262,6 +262,7 @@ struct mlx5_ib_mr { int npages; struct completion done; enum ib_wc_status status; + struct mlx5_core_sig_ctx*sig; }; struct mlx5_ib_fast_reg_page_list { @@ -489,6 +490,9 @@ struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, u64 virt_addr, int access_flags, struct ib_udata *udata); int mlx5_ib_dereg_mr(struct ib_mr *ibmr); +int mlx5_ib_destroy_mr(struct ib_mr *ibmr); +struct ib_mr *mlx5_ib_create_mr(struct ib_pd *pd, + struct ib_mr_init_attr *mr_init_attr); struct ib_mr *mlx5_ib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len); struct ib_fast_reg_page_list *mlx5_ib_alloc_fast_reg_page_list(struct ib_device *ibdev, diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index bd41df9..44f7e46 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -921,6 +921,115 @@ int mlx5_ib_dereg_mr(struct ib_mr *ibmr) return 0; } +struct ib_mr *mlx5_ib_create_mr(struct ib_pd *pd, + struct ib_mr_init_attr *mr_init_attr) +{ + struct mlx5_ib_dev *dev = to_mdev(pd-device); + struct mlx5_create_mkey_mbox_in *in; + struct mlx5_ib_mr *mr; + int access_mode, err; + int ndescs = roundup(mr_init_attr-max_reg_descriptors, 4); + + mr = kzalloc(sizeof(*mr), GFP_KERNEL); + if (!mr) + return ERR_PTR(-ENOMEM); + + in = kzalloc(sizeof(*in), GFP_KERNEL); + if (!in) { + err = -ENOMEM; + goto err_free; + } + + in-seg.status = 1 6; /* free */ + in-seg.xlt_oct_size = cpu_to_be32(ndescs); + in-seg.qpn_mkey7_0 = cpu_to_be32(0xff 8); + in-seg.flags_pd = cpu_to_be32(to_mpd(pd)-pdn); + access_mode = MLX5_ACCESS_MODE_MTT; + + if (mr_init_attr-flags IB_MR_SIGNATURE_EN) { + u32 psv_index[2]; + + in-seg.flags_pd = cpu_to_be32(be32_to_cpu(in-seg.flags_pd) | + MLX5_MKEY_BSF_EN); + in-seg.bsfs_octo_size = cpu_to_be32(MLX5_MKEY_BSF_OCTO_SIZE); + mr-sig = kzalloc(sizeof(*mr-sig), GFP_KERNEL); + if (!mr-sig) { + err = -ENOMEM; + goto err_free; + } + + /* create mem wire PSVs */ + err = mlx5_core_create_psv(dev-mdev, to_mpd(pd)-pdn, + 2, psv_index); + if (err) + goto err_free_sig; + + access_mode = MLX5_ACCESS_MODE_KLM; + mr-sig-psv_memory.psv_idx = psv_index[0]; +
Re: [PATCH RFC v2 03/10] IB/mlx5, mlx5_core: Support for create_mr and destroy_mr
On 10/31/2013 01:24 PM, Sagi Grimberg wrote: Support create_mr and destroy_mr verbs. Creating ib_mr may be done for either ib_mr that will register regular page lists like alloc_fast_reg_mr routine, or indirect ib_mr's that can register other (pre-registered) ib_mr's in an indirect manner. In addition user may request signature enable, that will mean that the created ib_mr may be attached with signature attributes (BSF, PSVs). Currently we only allow direct/indirect registration modes. Signed-off-by: Sagi Grimberg sa...@mellanox.com --- drivers/infiniband/hw/mlx5/main.c|2 + drivers/infiniband/hw/mlx5/mlx5_ib.h |4 + drivers/infiniband/hw/mlx5/mr.c | 109 ++ drivers/net/ethernet/mellanox/mlx5/core/mr.c | 64 +++ include/linux/mlx5/device.h | 25 ++ include/linux/mlx5/driver.h | 19 + 6 files changed, 223 insertions(+), 0 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 3f831de..2e67a37 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -1401,9 +1401,11 @@ static int init_one(struct pci_dev *pdev, dev-ib_dev.get_dma_mr = mlx5_ib_get_dma_mr; dev-ib_dev.reg_user_mr = mlx5_ib_reg_user_mr; dev-ib_dev.dereg_mr= mlx5_ib_dereg_mr; + dev-ib_dev.destroy_mr = mlx5_ib_destroy_mr; dev-ib_dev.attach_mcast= mlx5_ib_mcg_attach; dev-ib_dev.detach_mcast= mlx5_ib_mcg_detach; dev-ib_dev.process_mad = mlx5_ib_process_mad; + dev-ib_dev.create_mr = mlx5_ib_create_mr; dev-ib_dev.alloc_fast_reg_mr = mlx5_ib_alloc_fast_reg_mr; dev-ib_dev.alloc_fast_reg_page_list = mlx5_ib_alloc_fast_reg_page_list; dev-ib_dev.free_fast_reg_page_list = mlx5_ib_free_fast_reg_page_list; diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h index 836be91..45d7424 100644 --- a/drivers/infiniband/hw/mlx5/mlx5_ib.h +++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h @@ -262,6 +262,7 @@ struct mlx5_ib_mr { int npages; struct completion done; enum ib_wc_status status; + struct mlx5_core_sig_ctx*sig; }; struct mlx5_ib_fast_reg_page_list { @@ -489,6 +490,9 @@ struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, u64 virt_addr, int access_flags, struct ib_udata *udata); int mlx5_ib_dereg_mr(struct ib_mr *ibmr); +int mlx5_ib_destroy_mr(struct ib_mr *ibmr); +struct ib_mr *mlx5_ib_create_mr(struct ib_pd *pd, + struct ib_mr_init_attr *mr_init_attr); struct ib_mr *mlx5_ib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len); struct ib_fast_reg_page_list *mlx5_ib_alloc_fast_reg_page_list(struct ib_device *ibdev, diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index bd41df9..44f7e46 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -921,6 +921,115 @@ int mlx5_ib_dereg_mr(struct ib_mr *ibmr) return 0; } +struct ib_mr *mlx5_ib_create_mr(struct ib_pd *pd, + struct ib_mr_init_attr *mr_init_attr) +{ + struct mlx5_ib_dev *dev = to_mdev(pd-device); + struct mlx5_create_mkey_mbox_in *in; + struct mlx5_ib_mr *mr; + int access_mode, err; + int ndescs = roundup(mr_init_attr-max_reg_descriptors, 4); + + mr = kzalloc(sizeof(*mr), GFP_KERNEL); + if (!mr) + return ERR_PTR(-ENOMEM); + + in = kzalloc(sizeof(*in), GFP_KERNEL); + if (!in) { + err = -ENOMEM; + goto err_free; + } + + in-seg.status = 1 6; /* free */ + in-seg.xlt_oct_size = cpu_to_be32(ndescs); + in-seg.qpn_mkey7_0 = cpu_to_be32(0xff 8); + in-seg.flags_pd = cpu_to_be32(to_mpd(pd)-pdn); + access_mode = MLX5_ACCESS_MODE_MTT; + + if (mr_init_attr-flags IB_MR_SIGNATURE_EN) { + u32 psv_index[2]; + + in-seg.flags_pd = cpu_to_be32(be32_to_cpu(in-seg.flags_pd) | +MLX5_MKEY_BSF_EN); + in-seg.bsfs_octo_size = cpu_to_be32(MLX5_MKEY_BSF_OCTO_SIZE); + mr-sig = kzalloc(sizeof(*mr-sig), GFP_KERNEL); + if (!mr-sig) { + err = -ENOMEM; + goto err_free; + } + + /* create mem wire PSVs */ + err = mlx5_core_create_psv(dev-mdev, to_mpd(pd)-pdn, +2, psv_index); + if (err) + goto err_free_sig; + + access_mode = MLX5_ACCESS_MODE_KLM; +
Re: [PATCH RFC v2 00/10] Introduce Signature feature
Hi Sagi, I wander what's the performance overhead with this DIF support? And is there a roadmap for support SRP/ISER and target side for DIF? Regards, Jack On 10/31/2013 01:24 PM, Sagi Grimberg wrote: This patchset Introduces Verbs level support for signature handover feature. Siganture is intended to implement end-to-end data integrity on a transactional basis in a completely offloaded manner. There are several end-to-end data integrity methods used today in various applications and/or upper layer protocols such as T10-DIF defined by SCSI specifications (SBC), CRC32, XOR8 and more. This patchset adds verbs support only for T10-DIF. The proposed framework allows adding more signature methods in the future. In T10-DIF, when a series of 512-byte data blocks are transferred, each block is followed by an 8-byte guard. The guard consists of CRC that protects the integrity of the data in the block, and some other tags that protects against mis-directed IOs. Data can be protected when transferred over the wire, but can also be protected in the memory of the sender/receiver. This allows true end- to-end protection against bits flipping either over the wire, through gateways, in memory, over PCI, etc. While T10-DIF clearly defines that over the wire protection guards are interleaved into the data stream (each 512-Byte block followed by 8-byte guard), when in memory, the protection guards may reside in a buffer separated from the data. Depending on the application, it is usually easier to handle the data when it is contiguous. In this case the data buffer will be of size 512xN and the protection buffer will be of size 8xN (where N is the number of blocks in the transaction). There are 3 kinds of signature handover operation: 1. Take unprotected data (from wire or memory) and ADD protection guards. 2. Take protetected data (from wire or memory), validate the data integrity against the protection guards and STRIP the protection guards. 3. Take protected data (from wire or memory), validate the data integrity against the protection guards and PASS the data with the guards as-is. This translates to defining to the HCA how/if data protection exists in memory domain, and how/if data protection exists is wire domain. The way that data integrity is performed is by using a new kind of memory region: signature-enabled MR, and a new kind of work request: REG_SIG_MR. The REG_SIG_MR WR operates on the signature-enabled MR, and defines all the needed information for the signature handover (data buffer, protection buffer if needed and signature attributes). The result is an MR that can be used for data transfer as usual, that will also add/validate/strip/pass protection guards. When the data transfer is successfully completed, it does not mean that there are no integrity errors. The user must afterwards check the signature status of the handover operation using a new light-weight verb. This feature shall be used in storage upper layer protocols iSER/SRP implementing end-to-end data integrity T10-DIF. Following this patchset, we will soon submit krping patches which will demonstrate the usage of these signature verbs. -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH RFC v2 03/10] IB/mlx5, mlx5_core: Support for create_mr and destroy_mr
On 10/31/2013 2:52 PM, Jack Wang wrote: On 10/31/2013 01:24 PM, Sagi Grimberg wrote: Support create_mr and destroy_mr verbs. Creating ib_mr may be done for either ib_mr that will register regular page lists like alloc_fast_reg_mr routine, or indirect ib_mr's that can register other (pre-registered) ib_mr's in an indirect manner. In addition user may request signature enable, that will mean that the created ib_mr may be attached with signature attributes (BSF, PSVs). Currently we only allow direct/indirect registration modes. Signed-off-by: Sagi Grimberg sa...@mellanox.com --- drivers/infiniband/hw/mlx5/main.c|2 + drivers/infiniband/hw/mlx5/mlx5_ib.h |4 + drivers/infiniband/hw/mlx5/mr.c | 109 ++ drivers/net/ethernet/mellanox/mlx5/core/mr.c | 64 +++ include/linux/mlx5/device.h | 25 ++ include/linux/mlx5/driver.h | 19 + 6 files changed, 223 insertions(+), 0 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 3f831de..2e67a37 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -1401,9 +1401,11 @@ static int init_one(struct pci_dev *pdev, dev-ib_dev.get_dma_mr = mlx5_ib_get_dma_mr; dev-ib_dev.reg_user_mr = mlx5_ib_reg_user_mr; dev-ib_dev.dereg_mr = mlx5_ib_dereg_mr; + dev-ib_dev.destroy_mr = mlx5_ib_destroy_mr; dev-ib_dev.attach_mcast = mlx5_ib_mcg_attach; dev-ib_dev.detach_mcast = mlx5_ib_mcg_detach; dev-ib_dev.process_mad = mlx5_ib_process_mad; + dev-ib_dev.create_mr= mlx5_ib_create_mr; dev-ib_dev.alloc_fast_reg_mr= mlx5_ib_alloc_fast_reg_mr; dev-ib_dev.alloc_fast_reg_page_list = mlx5_ib_alloc_fast_reg_page_list; dev-ib_dev.free_fast_reg_page_list = mlx5_ib_free_fast_reg_page_list; diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h index 836be91..45d7424 100644 --- a/drivers/infiniband/hw/mlx5/mlx5_ib.h +++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h @@ -262,6 +262,7 @@ struct mlx5_ib_mr { int npages; struct completion done; enum ib_wc_status status; + struct mlx5_core_sig_ctx*sig; }; struct mlx5_ib_fast_reg_page_list { @@ -489,6 +490,9 @@ struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, u64 virt_addr, int access_flags, struct ib_udata *udata); int mlx5_ib_dereg_mr(struct ib_mr *ibmr); +int mlx5_ib_destroy_mr(struct ib_mr *ibmr); +struct ib_mr *mlx5_ib_create_mr(struct ib_pd *pd, + struct ib_mr_init_attr *mr_init_attr); struct ib_mr *mlx5_ib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len); struct ib_fast_reg_page_list *mlx5_ib_alloc_fast_reg_page_list(struct ib_device *ibdev, diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index bd41df9..44f7e46 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -921,6 +921,115 @@ int mlx5_ib_dereg_mr(struct ib_mr *ibmr) return 0; } +struct ib_mr *mlx5_ib_create_mr(struct ib_pd *pd, + struct ib_mr_init_attr *mr_init_attr) +{ + struct mlx5_ib_dev *dev = to_mdev(pd-device); + struct mlx5_create_mkey_mbox_in *in; + struct mlx5_ib_mr *mr; + int access_mode, err; + int ndescs = roundup(mr_init_attr-max_reg_descriptors, 4); + + mr = kzalloc(sizeof(*mr), GFP_KERNEL); + if (!mr) + return ERR_PTR(-ENOMEM); + + in = kzalloc(sizeof(*in), GFP_KERNEL); + if (!in) { + err = -ENOMEM; + goto err_free; + } + + in-seg.status = 1 6; /* free */ + in-seg.xlt_oct_size = cpu_to_be32(ndescs); + in-seg.qpn_mkey7_0 = cpu_to_be32(0xff 8); + in-seg.flags_pd = cpu_to_be32(to_mpd(pd)-pdn); + access_mode = MLX5_ACCESS_MODE_MTT; + + if (mr_init_attr-flags IB_MR_SIGNATURE_EN) { + u32 psv_index[2]; + + in-seg.flags_pd = cpu_to_be32(be32_to_cpu(in-seg.flags_pd) | + MLX5_MKEY_BSF_EN); + in-seg.bsfs_octo_size = cpu_to_be32(MLX5_MKEY_BSF_OCTO_SIZE); + mr-sig = kzalloc(sizeof(*mr-sig), GFP_KERNEL); + if (!mr-sig) { + err = -ENOMEM; + goto err_free; + } + + /* create mem wire PSVs */ + err = mlx5_core_create_psv(dev-mdev, to_mpd(pd)-pdn, + 2, psv_index); + if (err) + goto err_free_sig;
Re: [PATCH RFC v2 08/10] IB/mlx5: Support IB_WR_REG_SIG_MR
On 10/31/2013 01:24 PM, Sagi Grimberg wrote: +{ + struct ib_mr *sig_mr = wr-wr.sig_handover.sig_mr; + u32 sig_key = sig_mr-rkey; + + memset(seg, 0, sizeof(*seg)); + + seg-status = 0x4; /*set free*/ + seg-flags = get_umr_flags(wr-wr.sig_handover.access_flags) | +MLX5_ACCESS_MODE_KLM; + seg-qpn_mkey7_0 = cpu_to_be32((sig_key 0xff) | 0xff00); + seg-flags_pd = cpu_to_be32(MLX5_MKEY_REMOTE_INVAL | + MLX5_MKEY_BSF_EN | pdn); + seg-start_addr = 0; Already memset, no need to set start_addr here. Jack + seg-len = cpu_to_be64(length); + seg-xlt_oct_size = cpu_to_be32(be16_to_cpu(get_klm_octo(nelements))); + seg-bsfs_octo_size = cpu_to_be32(MLX5_MKEY_BSF_OCTO_SIZE); +} + -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH RFC v2 00/10] Introduce Signature feature
On 10/31/2013 2:55 PM, Jack Wang wrote: Hi Sagi, I wander what's the performance overhead with this DIF support? And is there a roadmap for support SRP/ISER and target side for DIF? Regards, Jack Well, all DIF operations are fully offloaded by the HCA so we don't expect any performance degradation other than the obvious 8-bytes integrity overhead. We have yet to take benchmarks on this and we definitely plan to do so. Regarding our roadmap, we plan to support iSER target (LIO) and initiator first. Some prior support for DIF needs to be added in target core level, then transport implementation is pretty straight-forward (iSER/SRP). So I aim for iSER DIF support (target+initiator) to make it into v3.14. Hope this helps, Sagi. -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH for-next 0/6] mlx5 and mlx4 drivers updates and fixes for 3.13
Hi Roland, Here are some some fixes to mlx4 and mlx5 driver for the 3.13 merge window. Thanks, Eli Eli Cohen (6): IB/mlx5: Remove dead code IB/core: Encorce MR access rights rules on kernel consumers IB/mlx5: Fix list_del of empty list IB/mlx4: Fix device max capabilities check IB/mlx4: Fix endless loop in resize CQ IB/mlx5: Fix page shift in create CQ for userspace drivers/infiniband/core/uverbs_cmd.c| 10 +++--- drivers/infiniband/core/verbs.c | 14 ++ drivers/infiniband/hw/mlx4/cq.c | 9 +++-- drivers/infiniband/hw/mlx5/cq.c | 2 +- drivers/infiniband/hw/mlx5/mr.c | 5 - drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | 3 ++- include/rdma/ib_verbs.h | 13 + 7 files changed, 40 insertions(+), 16 deletions(-) -- 1.8.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH for-next 2/6] IB/core: Encorce MR access rights rules on kernel consumers
Enforce the rule that when requesting remote write or atomic permissions, local write must be indicated as well. See IB spec 11.2.8.2. Spotted by: Hagay Abramovsky hag...@mellanox.com Signed-off-by: Eli Cohen e...@mellanox.com --- drivers/infiniband/core/uverbs_cmd.c | 10 +++--- drivers/infiniband/core/verbs.c | 14 ++ include/rdma/ib_verbs.h | 13 + 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 5bb2a82d..7f671b7 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -939,13 +939,9 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file, if ((cmd.start ~PAGE_MASK) != (cmd.hca_va ~PAGE_MASK)) return -EINVAL; - /* -* Local write permission is required if remote write or -* remote atomic permission is also requested. -*/ - if (cmd.access_flags (IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_REMOTE_WRITE) - !(cmd.access_flags IB_ACCESS_LOCAL_WRITE)) - return -EINVAL; + ret = ib_check_mr_access(cmd.access_flags); + if (ret) + return ret; uobj = kmalloc(sizeof *uobj, GFP_KERNEL); if (!uobj) diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index a321df2..b7f21d7 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -958,6 +958,11 @@ EXPORT_SYMBOL(ib_resize_cq); struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags) { struct ib_mr *mr; + int err; + + err = ib_check_mr_access(mr_access_flags); + if (err) + return ERR_PTR(err); mr = pd-device-get_dma_mr(pd, mr_access_flags); @@ -980,6 +985,11 @@ struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd, u64 *iova_start) { struct ib_mr *mr; + int err; + + err = ib_check_mr_access(mr_access_flags); + if (err) + return ERR_PTR(err); if (!pd-device-reg_phys_mr) return ERR_PTR(-ENOSYS); @@ -1010,6 +1020,10 @@ int ib_rereg_phys_mr(struct ib_mr *mr, struct ib_pd *old_pd; int ret; + ret = ib_check_mr_access(mr_access_flags); + if (ret) + return ret; + if (!mr-device-rereg_phys_mr) return -ENOSYS; diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index e393171..8f462a6 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2384,4 +2384,17 @@ struct ib_flow *ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_attr, int domain); int ib_destroy_flow(struct ib_flow *flow_id); +static inline int ib_check_mr_access(int flags) +{ + /* +* Local write permission is required if remote write or +* remote atomic permission is also requested. +*/ + if (flags (IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_REMOTE_WRITE) + !(flags IB_ACCESS_LOCAL_WRITE)) + return -EINVAL; + + return 0; +} + #endif /* IB_VERBS_H */ -- 1.8.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH for-next 1/6] IB/mlx5: Remove dead code
The value of the local variable index is never used in reg_mr_callback(). Signed-off-by: Eli Cohen e...@mellanox.com --- drivers/infiniband/hw/mlx5/mr.c | 5 - 1 file changed, 5 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index 2c4626f..2fa54d1 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -73,13 +73,8 @@ static void reg_mr_callback(int status, void *context) struct mlx5_cache_ent *ent = cache-ent[c]; u8 key; unsigned long delta = jiffies - mr-start; - unsigned long index; unsigned long flags; - index = find_last_bit(delta, 8 * sizeof(delta)); - if (index == 64) - index = 0; - spin_lock_irqsave(ent-lock, flags); ent-pending--; spin_unlock_irqrestore(ent-lock, flags); -- 1.8.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH for-next 3/6] IB/mlx5: Fix list_del of empty list
For archs with pages size of 4K, when the chunk is freed, fwp is not in the list so avoid attempting to delete it. Signed-off-by: Eli Cohen e...@mellanox.com --- drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c index ba816c2..37b6ad1 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c @@ -229,7 +229,8 @@ static void free_4k(struct mlx5_core_dev *dev, u64 addr) set_bit(n, fwp-bitmask); if (fwp-free_count == MLX5_NUM_4K_IN_PAGE) { rb_erase(fwp-rb_node, dev-priv.page_root); - list_del(fwp-list); + if (fwp-free_count != 1) + list_del(fwp-list); dma_unmap_page(dev-pdev-dev, addr, PAGE_SIZE, DMA_BIDIRECTIONAL); __free_page(fwp-page); kfree(fwp); -- 1.8.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH for-next 6/6] IB/mlx5: Fix page shift in create CQ for userspace
When creating a CQ, we must use mlx5 adapter page shift. Signed-off-by: Eli Cohen e...@mellanox.com --- drivers/infiniband/hw/mlx5/cq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c index 2834477..b726274 100644 --- a/drivers/infiniband/hw/mlx5/cq.c +++ b/drivers/infiniband/hw/mlx5/cq.c @@ -556,7 +556,7 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata, goto err_db; } mlx5_ib_populate_pas(dev, cq-buf.umem, page_shift, (*cqb)-pas, 0); - (*cqb)-ctx.log_pg_sz = page_shift - PAGE_SHIFT; + (*cqb)-ctx.log_pg_sz = page_shift - MLX5_ADAPTER_PAGE_SHIFT; *index = to_mucontext(context)-uuari.uars[0].index; -- 1.8.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH for-next 5/6] IB/mlx4: Fix endless loop in resize CQ
When calling get_sw_cqe() we need pass the consumer_index and not the masked value. Failure to do so will cause incorrect result of get_sw_cqe() possibly leading to endless loop. This problem was reported and analyzed by Michael Rice from HP. Issue: 346608 Signed-off-by: Eli Cohen e...@mellanox.com --- drivers/infiniband/hw/mlx4/cq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c index ea29951..66dbf80 100644 --- a/drivers/infiniband/hw/mlx4/cq.c +++ b/drivers/infiniband/hw/mlx4/cq.c @@ -324,7 +324,7 @@ static int mlx4_ib_get_outstanding_cqes(struct mlx4_ib_cq *cq) u32 i; i = cq-mcq.cons_index; - while (get_sw_cqe(cq, i cq-ibcq.cqe)) + while (get_sw_cqe(cq, i)) ++i; return i - cq-mcq.cons_index; -- 1.8.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH for-next 4/6] IB/mlx4: Fix device max capabilities check
Move the check on max supported CQEs after the final number of entries is evaluated. Signed-off-by: Eli Cohen e...@mellanox.com --- drivers/infiniband/hw/mlx4/cq.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c index d5e60f4..ea29951 100644 --- a/drivers/infiniband/hw/mlx4/cq.c +++ b/drivers/infiniband/hw/mlx4/cq.c @@ -365,7 +365,7 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata) mutex_lock(cq-resize_mutex); - if (entries 1 || entries dev-dev-caps.max_cqes) { + if (entries 1) { err = -EINVAL; goto out; } @@ -376,6 +376,11 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata) goto out; } + if (entries dev-dev-caps.max_cqes) { + err = -EINVAL; + goto out; + } + if (ibcq-uobject) { err = mlx4_alloc_resize_umem(dev, cq, entries, udata); if (err) -- 1.8.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH RFC v2 00/10] Introduce Signature feature
On 10/31/2013 02:20 PM, Sagi Grimberg wrote: On 10/31/2013 2:55 PM, Jack Wang wrote: Hi Sagi, I wander what's the performance overhead with this DIF support? And is there a roadmap for support SRP/ISER and target side for DIF? Regards, Jack Well, all DIF operations are fully offloaded by the HCA so we don't expect any performance degradation other than the obvious 8-bytes integrity overhead. We have yet to take benchmarks on this and we definitely plan to do so. Regarding our roadmap, we plan to support iSER target (LIO) and initiator first. Some prior support for DIF needs to be added in target core level, then transport implementation is pretty straight-forward (iSER/SRP). So I aim for iSER DIF support (target+initiator) to make it into v3.14. Hope this helps, Sagi. Good to know, thanks Jack -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH for-next 2/2] IB/mlx4: Fix build warnings
Fix the below make W=1 build warning we have on the mlx4_ib drivers/infiniband/hw/mlx4/qp.c: In function ‘mlx4_ib_post_send’: drivers/infiniband/hw/mlx4/qp.c:2463: warning: comparison of unsigned expression 0 is always false Signed-off-by: Or Gerlitz ogerl...@mellanox.com --- drivers/infiniband/hw/mlx4/qp.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c index 4f10af2..da25e4d 100644 --- a/drivers/infiniband/hw/mlx4/qp.c +++ b/drivers/infiniband/hw/mlx4/qp.c @@ -2460,7 +2460,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, */ wmb(); - if (wr-opcode 0 || wr-opcode = ARRAY_SIZE(mlx4_ib_opcode)) { + if (wr-opcode = ARRAY_SIZE(mlx4_ib_opcode)) { *bad_wr = wr; err = -EINVAL; goto out; -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH for-next 0/2] Fix build warnings
Hi Roland, This little patch set removes the current make W=1 build warnings from the IB core and the mlx4_ib driver, which would help when we examine new patches to make sure they don't add any warnings.. Or. Or Gerlitz (2): IB/core: Fix build warnings IB/mlx4: Fix build warnings drivers/infiniband/core/iwcm.c |2 -- drivers/infiniband/core/sysfs.c |2 +- drivers/infiniband/core/verbs.c |3 +-- drivers/infiniband/hw/mlx4/qp.c |2 +- 4 files changed, 3 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH for-next 1/2] IB/core: Fix build warnings
Fix the below few make W=1 build warnings we have on the IB core. drivers/infiniband/core/sysfs.c: In function ‘state_show’: drivers/infiniband/core/sysfs.c:107: warning: comparison of unsigned expression = 0 is always true drivers/infiniband/core/verbs.c: In function ‘ib_modify_qp_is_ok’: drivers/infiniband/core/verbs.c:783: warning: comparison of unsigned expression 0 is always false drivers/infiniband/core/verbs.c:784: warning: comparison of unsigned expression 0 is always false drivers/infiniband/core/iwcm.c: In function ‘destroy_cm_id’: drivers/infiniband/core/iwcm.c:330: warning: variable ‘ret’ set but not used Signed-off-by: Or Gerlitz ogerl...@mellanox.com --- drivers/infiniband/core/iwcm.c |2 -- drivers/infiniband/core/sysfs.c |2 +- drivers/infiniband/core/verbs.c |3 +-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c index c47c203..ab8ebf8 100644 --- a/drivers/infiniband/core/iwcm.c +++ b/drivers/infiniband/core/iwcm.c @@ -327,7 +327,6 @@ static void destroy_cm_id(struct iw_cm_id *cm_id) { struct iwcm_id_private *cm_id_priv; unsigned long flags; - int ret; cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); /* @@ -343,7 +342,6 @@ static void destroy_cm_id(struct iw_cm_id *cm_id) cm_id_priv-state = IW_CM_STATE_DESTROYING; spin_unlock_irqrestore(cm_id_priv-lock, flags); /* destroy the listening endpoint */ - ret = cm_id-device-iwcm-destroy_listen(cm_id); spin_lock_irqsave(cm_id_priv-lock, flags); break; case IW_CM_STATE_ESTABLISHED: diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index cde1e7b..1184050 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -104,7 +104,7 @@ static ssize_t state_show(struct ib_port *p, struct port_attribute *unused, return ret; return sprintf(buf, %d: %s\n, attr.state, - attr.state = 0 attr.state ARRAY_SIZE(state_name) ? + attr.state ARRAY_SIZE(state_name) ? state_name[attr.state] : UNKNOWN); } diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index a321df2..7b0c1f4 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -780,8 +780,7 @@ int ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state, { enum ib_qp_attr_mask req_param, opt_param; - if (cur_state 0 || cur_state IB_QPS_ERR || - next_state 0 || next_state IB_QPS_ERR) + if (cur_state IB_QPS_ERR || next_state IB_QPS_ERR) return 0; if (mask IB_QP_CUR_STATE -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH for-next 1/2] IB/core: Fix build warnings
On 31/10/2013 9:21, Or Gerlitz wrote: Fix the below few make W=1 build warnings we have on the IB core. drivers/infiniband/core/sysfs.c: In function ‘state_show’: drivers/infiniband/core/sysfs.c:107: warning: comparison of unsigned expression = 0 is always true drivers/infiniband/core/verbs.c: In function ‘ib_modify_qp_is_ok’: drivers/infiniband/core/verbs.c:783: warning: comparison of unsigned expression 0 is always false drivers/infiniband/core/verbs.c:784: warning: comparison of unsigned expression 0 is always false drivers/infiniband/core/iwcm.c: In function ‘destroy_cm_id’: drivers/infiniband/core/iwcm.c:330: warning: variable ‘ret’ set but not used Signed-off-by: Or Gerlitz ogerl...@mellanox.com --- drivers/infiniband/core/iwcm.c |2 -- drivers/infiniband/core/sysfs.c |2 +- drivers/infiniband/core/verbs.c |3 +-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c index c47c203..ab8ebf8 100644 --- a/drivers/infiniband/core/iwcm.c +++ b/drivers/infiniband/core/iwcm.c @@ -327,7 +327,6 @@ static void destroy_cm_id(struct iw_cm_id *cm_id) { struct iwcm_id_private *cm_id_priv; unsigned long flags; - int ret; cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); /* @@ -343,7 +342,6 @@ static void destroy_cm_id(struct iw_cm_id *cm_id) cm_id_priv-state = IW_CM_STATE_DESTROYING; spin_unlock_irqrestore(cm_id_priv-lock, flags); /* destroy the listening endpoint */ - ret = cm_id-device-iwcm-destroy_listen(cm_id); spin_lock_irqsave(cm_id_priv-lock, flags); break; case IW_CM_STATE_ESTABLISHED: diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index cde1e7b..1184050 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -104,7 +104,7 @@ static ssize_t state_show(struct ib_port *p, struct port_attribute *unused, return ret; return sprintf(buf, %d: %s\n, attr.state, - attr.state = 0 attr.state ARRAY_SIZE(state_name) ? + attr.state ARRAY_SIZE(state_name) ? state_name[attr.state] : UNKNOWN); } diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index a321df2..7b0c1f4 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -780,8 +780,7 @@ int ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state, { enum ib_qp_attr_mask req_param, opt_param; - if (cur_state 0 || cur_state IB_QPS_ERR || - next_state 0 || next_state IB_QPS_ERR) + if (cur_state IB_QPS_ERR || next_state IB_QPS_ERR) return 0; if (mask IB_QP_CUR_STATE I agree that removing unused variables is good because it makes source code easier to read. However, removing the attr.state = 0 check from state_show() looks dangerous to me. If the type of that variable would ever be changed from unsigned to signed then that would break state_show() in a very subtle way. It could take a long time before such breakage is detected. How about modifying the behavior of W=1 such that it doesn't warn about comparisons that are always true (-Wno-type-limits) ? Bart. -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH for-next 1/2] IB/core: Fix build warnings
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c index c47c203..ab8ebf8 100644 --- a/drivers/infiniband/core/iwcm.c +++ b/drivers/infiniband/core/iwcm.c @@ -327,7 +327,6 @@ static void destroy_cm_id(struct iw_cm_id *cm_id) { struct iwcm_id_private *cm_id_priv; unsigned long flags; - int ret; cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); /* @@ -343,7 +342,6 @@ static void destroy_cm_id(struct iw_cm_id *cm_id) cm_id_priv-state = IW_CM_STATE_DESTROYING; spin_unlock_irqrestore(cm_id_priv-lock, flags); /* destroy the listening endpoint */ - ret = cm_id-device-iwcm-destroy_listen(cm_id); removing 'ret' is one thing, removing the call to destroy_listen() is another.
Re: [PATCH for-next 1/2] IB/core: Fix build warnings
On Thu, 2013-10-31 at 10:02 -0700, Bart Van Assche wrote: On 31/10/2013 9:21, Or Gerlitz wrote: --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -104,7 +104,7 @@ static ssize_t state_show(struct ib_port *p, struct port_attribute *unused, return ret; return sprintf(buf, %d: %s\n, attr.state, - attr.state = 0 attr.state ARRAY_SIZE(state_name) ? + attr.state ARRAY_SIZE(state_name) ? state_name[attr.state] : UNKNOWN); } I agree that removing unused variables is good because it makes source code easier to read. However, removing the attr.state = 0 check from state_show() looks dangerous to me. If the type of that variable would ever be changed from unsigned to signed then that would break state_show() in a very subtle way. It could take a long time before such breakage is detected. How about modifying the behavior of W=1 such that it doesn't warn about comparisons that are always true (-Wno-type-limits) ? We want to know about those comparisons, because they often indicate a bug -- either in one's thinking, or in the code they've written. Changing attr.state from unsigned to signed is unlikely to ever happen, as a massive audit would be needed -- this is not an uncommon pattern in the kernel. -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH for-next 1/2] IB/core: Fix build warnings
On Thu, Oct 31, 2013 at 7:59 PM, Hefty, Sean sean.he...@intel.com wrote: removing 'ret' is one thing, removing the call to destroy_listen() is another. sure, I will fix and resubmit -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html