History

RDMA/vmw_pvrdma: Cleanup unused variables

Removed the unused nreq and redundant index variables. Moved hardcoded async and cq ring pages number to macro.

Adit Ranadive committed 9 years ago

Commit 6332dee1 parent cb886453 files · +17 −22Browse files

Unified · Split

3 files
  1. drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +2 −0
  2. drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +2 −2
  3. drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c +13 −20
drivers/infiniband/hw/vmw_pvrdma/pvrdma.h+2−0
@@ -69,6 +69,8 @@ · 68 unmodified lines
6969 */
7070 #define PCI_DEVICE_ID_VMWARE_PVRDMA 0x0820
7171
72+#define PVRDMA_NUM_RING_PAGES 4
73+
7274 struct pvrdma_dev;
7375
7476 struct pvrdma_page_dir {
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c+2−2
@@ -858,7 +858,7 @@ static int pvrdma_pci_probe(struct pci_dev *pdev, · 857 unmodified lines
858858 dev->dsr->resp_slot_dma = (u64)slot_dma;
859859
860860 /* Async event ring */
861− dev->dsr->async_ring_pages.num_pages = 4;
861+ dev->dsr->async_ring_pages.num_pages = PVRDMA_NUM_RING_PAGES;
862862 ret = pvrdma_page_dir_init(dev, &dev->async_pdir,
863863 dev->dsr->async_ring_pages.num_pages, true);
864864 if (ret)
@@ -867,7 +867,7 @@ static int pvrdma_pci_probe(struct pci_dev *pdev, · 2 unmodified lines
867867 dev->dsr->async_ring_pages.pdir_dma = dev->async_pdir.dir_dma;
868868
869869 /* CQ notification ring */
870− dev->dsr->cq_ring_pages.num_pages = 4;
870+ dev->dsr->cq_ring_pages.num_pages = PVRDMA_NUM_RING_PAGES;
871871 ret = pvrdma_page_dir_init(dev, &dev->cq_pdir,
872872 dev->dsr->cq_ring_pages.num_pages, true);
873873 if (ret)
drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c+13−20
@@ -554,13 +554,13 @@ out: · 553 unmodified lines
554554 return ret;
555555 }
556556
557−static inline void *get_sq_wqe(struct pvrdma_qp *qp, int n)
557+static inline void *get_sq_wqe(struct pvrdma_qp *qp, unsigned int n)
558558 {
559559 return pvrdma_page_dir_get_ptr(&qp->pdir,
560560 qp->sq.offset + n * qp->sq.wqe_size);
561561 }
562562
563−static inline void *get_rq_wqe(struct pvrdma_qp *qp, int n)
563+static inline void *get_rq_wqe(struct pvrdma_qp *qp, unsigned int n)
564564 {
565565 return pvrdma_page_dir_get_ptr(&qp->pdir,
566566 qp->rq.offset + n * qp->rq.wqe_size);
@@ -598,9 +598,7 @@ int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, · 31 unmodified lines
598598 unsigned long flags;
599599 struct pvrdma_sq_wqe_hdr *wqe_hdr;
600600 struct pvrdma_sge *sge;
601− int i, index;
602− int nreq;
603− int ret;
601+ int i, ret;
604602
605603 /*
606604 * In states lower than RTS, we can fail immediately. In other states,
@@ -613,9 +611,8 @@ int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, · 6 unmodified lines
613611
614612 spin_lock_irqsave(&qp->sq.lock, flags);
615613
616− index = pvrdma_idx(&qp->sq.ring->prod_tail, qp->sq.wqe_cnt);
617− for (nreq = 0; wr; nreq++, wr = wr->next) {
618− unsigned int tail;
614+ while (wr) {
615+ unsigned int tail = 0;
619616
620617 if (unlikely(!pvrdma_idx_ring_has_space(
621618 qp->sq.ring, qp->sq.wqe_cnt, &tail))) {
@@ -680,7 +677,7 @@ int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, · 58 unmodified lines
680677 }
681678 }
682679
683− wqe_hdr = (struct pvrdma_sq_wqe_hdr *)get_sq_wqe(qp, index);
680+ wqe_hdr = (struct pvrdma_sq_wqe_hdr *)get_sq_wqe(qp, tail);
684681 memset(wqe_hdr, 0, sizeof(*wqe_hdr));
685682 wqe_hdr->wr_id = wr->wr_id;
686683 wqe_hdr->num_sge = wr->num_sge;
@@ -771,12 +768,11 @@ int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, · 84 unmodified lines
771768 /* Make sure wqe is written before index update */
772769 smp_wmb();
773770
774− index++;
775− if (unlikely(index >= qp->sq.wqe_cnt))
776− index = 0;
777771 /* Update shared sq ring */
778772 pvrdma_idx_ring_inc(&qp->sq.ring->prod_tail,
779773 qp->sq.wqe_cnt);
774+
775+ wr = wr->next;
780776 }
781777
782778 ret = 0;
@@ -806,7 +802,6 @@ int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, · 23 unmodified lines
806802 struct pvrdma_qp *qp = to_vqp(ibqp);
807803 struct pvrdma_rq_wqe_hdr *wqe_hdr;
808804 struct pvrdma_sge *sge;
809− int index, nreq;
810805 int ret = 0;
811806 int i;
812807
@@ -821,9 +816,8 @@ int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, · 8 unmodified lines
821816
822817 spin_lock_irqsave(&qp->rq.lock, flags);
823818
824− index = pvrdma_idx(&qp->rq.ring->prod_tail, qp->rq.wqe_cnt);
825− for (nreq = 0; wr; nreq++, wr = wr->next) {
826− unsigned int tail;
819+ while (wr) {
820+ unsigned int tail = 0;
827821
828822 if (unlikely(wr->num_sge > qp->rq.max_sg ||
829823 wr->num_sge < 0)) {
@@ -843,7 +837,7 @@ int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, · 13 unmodified lines
843837 goto out;
844838 }
845839
846− wqe_hdr = (struct pvrdma_rq_wqe_hdr *)get_rq_wqe(qp, index);
840+ wqe_hdr = (struct pvrdma_rq_wqe_hdr *)get_rq_wqe(qp, tail);
847841 wqe_hdr->wr_id = wr->wr_id;
848842 wqe_hdr->num_sge = wr->num_sge;
849843 wqe_hdr->total_len = 0;
@@ -859,12 +853,11 @@ int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, · 9 unmodified lines
859853 /* Make sure wqe is written before index update */
860854 smp_wmb();
861855
862− index++;
863− if (unlikely(index >= qp->rq.wqe_cnt))
864− index = 0;
865856 /* Update shared rq ring */
866857 pvrdma_idx_ring_inc(&qp->rq.ring->prod_tail,
867858 qp->rq.wqe_cnt);
859+
860+ wr = wr->next;
868861 }
869862
870863 spin_unlock_irqrestore(&qp->rq.lock, flags);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t