Skip to contentSkip to conversation

nvme-rdma: fix in-casule data send for chained sgls

PATCH Superseded Sagi Grimberg 2 participants 3 messages May 27, 2021 – May 28, 2021 NVMe

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Sagi Grimberg

author maintainer
#0 lore raw

PATCH 1/1 nvme-rdma: fix in-casule data send for chained sgls

We have only 2 inline sg entries and we allow 4 sg entries for the send wr sge. Larger sgls entries will be chained. However when we build in-capsule send wr sge, we iterate without taking into account that the sgl may be chained and still fit in-capsule (which can happen if the sgl is bigger than 2, but lower-equal to 4).

Fix in-capsule data mapping to correctly iterate chained sgls.

---
 drivers/nvme/host/rdma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/host/rdma.c +2 -2
index 8d107b201f16..ed1bf214c544 100644
@@ -1320,16 +1320,16 @@ static int nvme_rdma_map_sg_inline(struct nvme_rdma_queue *queue,
 		int count)
 {
 	struct nvme_sgl_desc *sg = &c->common.dptr.sgl;
-	struct scatterlist *sgl = req->data_sgl.sg_table.sgl;
 	struct ib_sge *sge = &req->sge[1];
 	u32 len = 0;
 	int i;
 
-	for (i = 0; i < count; i++, sgl++, sge++) {
+	for_each_sg(req->data_sgl.sg_table.sgl, sgl, count, i) {
 		sge->addr = sg_dma_address(sgl);
 		sge->length = sg_dma_len(sgl);
 		sge->lkey = queue->device->pd->local_dma_lkey;
 		len += sge->length;
+		sge++;
 	}
 
 	sg->addr = cpu_to_le64(queue->ctrl->ctrl.icdoff);
Signature · 7 lines
2.27.0


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
#1 lore raw
Quoted 19 lines · Sagi Grimberg

We have only 2 inline sg entries and we allow 4 sg entries for the send wr sge. Larger sgls entries will be chained. However when we build in-capsule send wr sge, we iterate without taking into account that the sgl may be chained and still fit in-capsule (which can happen if the sgl is bigger than 2, but lower-equal to 4).

Fix in-capsule data mapping to correctly iterate chained sgls.

---
  drivers/nvme/host/rdma.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/host/rdma.c +0 -0
index 8d107b201f16..ed1bf214c544 100644

drivers/nvme/host/rdma.c static int nvme_rdma_map_sg_inline(struct nvme_rdma_queue *queue, · line 1323

Quoted 4 lines
drivers/nvme/host/rdma.c +0 -1
@@ -1320,16 +1320,16 @@ static int nvme_rdma_map_sg_inline(struct nvme_rdma_queue *queue,
  		int count)
  {
  	struct nvme_sgl_desc *sg = &c->common.dptr.sgl;
-	struct scatterlist *sgl = req->data_sgl.sg_table.sgl;

sgl need to be defined.

Quoted 5 lines
drivers/nvme/host/rdma.c +0 -0
  	struct ib_sge *sge = &req->sge[1];
  	u32 len = 0;
  	int i;
 

drivers/nvme/host/rdma.c static int nvme_rdma_map_sg_inline(struct nvme_rdma_queue *queue, · line 1335

Quoted 10 lines
drivers/nvme/host/rdma.c +2 -1
-	for (i = 0; i < count; i++, sgl++, sge++) {
+	for_each_sg(req->data_sgl.sg_table.sgl, sgl, count, i) {
  		sge->addr = sg_dma_address(sgl);
  		sge->length = sg_dma_len(sgl);
  		sge->lkey = queue->device->pd->local_dma_lkey;
  		len += sge->length;
+		sge++;
  	}
 
  	sg->addr = cpu_to_le64(queue->ctrl->ctrl.icdoff);

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

author maintainer
#2 lore raw
Quoted 16 lines · Sagi Grimberg
Quoted 14 lines

We have only 2 inline sg entries and we allow 4 sg entries for the send wr sge. Larger sgls entries will be chained. However when we build in-capsule send wr sge, we iterate without taking into account that the sgl may be chained and still fit in-capsule (which can happen if the sgl is bigger than 2, but lower-equal to 4).

Fix in-capsule data mapping to correctly iterate chained sgls.

---
  drivers/nvme/host/rdma.c | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 11 lines

drivers/nvme/host/rdma.c static int nvme_rdma_map_sg_inline(struct · line 1324

Quoted 10 lines
drivers/nvme/host/rdma.c +0 -1
index 8d107b201f16..ed1bf214c544 100644
@@ -1320,16 +1320,16 @@ static int nvme_rdma_map_sg_inline(struct 
 nvme_rdma_queue *queue,
           int count)
   {
       struct nvme_sgl_desc *sg = &c->common.dptr.sgl;
-    struct scatterlist *sgl = req->data_sgl.sg_table.sgl;

sgl need to be defined.

Obviously, rushed it...

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme