Re: [PATCH for-next 4/6] RDMA/hns: Filter for zero length of sge in hip08 kernel mode

Leon Romanovsky
2017-12-25T09:00:28Z

[-- Attachment #1: Type: text/plain, Size: 1211 bytes --]

On Sat, Dec 23, 2017 at 04:22:20PM +0800, Lijun Ou wrote:
> When the length of sge is zero, the driver need to filter it
>
> Signed-off-by: Lijun Ou <oulijun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> ---
> drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 29 ++++++++++++++++++++---------
> 1 file changed, 20 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> index 869e36f..a1d8ca0 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> @@ -230,26 +230,37 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
> V2_RC_SEND_WQE_BYTE_4_INLINE_S, 1);
> } else {
> if (wr->num_sge <= 2) {
> - for (i = 0; i < wr->num_sge; i++)
> - set_data_seg_v2(dseg + i,
> - wr->sg_list + i);
> + for (i = 0; i < wr->num_sge; i++) {
> + if (likely(wr->sg_list[i].length)) {
> + set_data_seg_v2(dseg,
> + wr->sg_list + i);
> + dseg++;

Actually, you don't need to advance desg and keep your "desg + i" code as before.

I have a more general question, is this scenario (having length == 0) real?

Thanks

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]