i40iw: Simplify code to set fragments in SQ WQE
authorMustafa Ismail <mustafa.ismail@intel.com>
Tue, 12 Jul 2016 16:48:43 +0000 (11:48 -0500)
committerDoug Ledford <dledford@redhat.com>
Tue, 2 Aug 2016 18:17:38 +0000 (14:17 -0400)
Replace a subtract and multiply with an add; while populating fragments
in SQ wqe.

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/i40iw/i40iw_uk.c

index cea0b8a5d7c5a8e9920d95bb85fedfbf5cfa618e..6b217e6e918f73043194b7018ee49532a24c77f2 100644 (file)
@@ -291,9 +291,9 @@ static enum i40iw_status_code i40iw_rdma_write(struct i40iw_qp_uk *qp,
 
        i40iw_set_fragment(wqe, 0, op_info->lo_sg_list);
 
-       for (i = 1; i < op_info->num_lo_sges; i++) {
-               byte_off = 32 + (i - 1) * 16;
+       for (i = 1, byte_off = 32; i < op_info->num_lo_sges; i++) {
                i40iw_set_fragment(wqe, byte_off, &op_info->lo_sg_list[i]);
+               byte_off += 16;
        }
 
        wmb(); /* make sure WQE is populated before valid bit is set */
@@ -401,9 +401,9 @@ static enum i40iw_status_code i40iw_send(struct i40iw_qp_uk *qp,
 
        i40iw_set_fragment(wqe, 0, op_info->sg_list);
 
-       for (i = 1; i < op_info->num_sges; i++) {
-               byte_off = 32 + (i - 1) * 16;
+       for (i = 1, byte_off = 32; i < op_info->num_sges; i++) {
                i40iw_set_fragment(wqe, byte_off, &op_info->sg_list[i]);
+               byte_off += 16;
        }
 
        wmb(); /* make sure WQE is populated before valid bit is set */
@@ -685,9 +685,9 @@ static enum i40iw_status_code i40iw_post_receive(struct i40iw_qp_uk *qp,
 
        i40iw_set_fragment(wqe, 0, info->sg_list);
 
-       for (i = 1; i < info->num_sges; i++) {
-               byte_off = 32 + (i - 1) * 16;
+       for (i = 1, byte_off = 32; i < info->num_sges; i++) {
                i40iw_set_fragment(wqe, byte_off, &info->sg_list[i]);
+               byte_off += 16;
        }
 
        wmb(); /* make sure WQE is populated before valid bit is set */