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
69 */69 */
70#define PCI_DEVICE_ID_VMWARE_PVRDMA 0x082070#define PCI_DEVICE_ID_VMWARE_PVRDMA 0x0820
71 71
72#define PVRDMA_NUM_RING_PAGES 4
73
72struct pvrdma_dev;74struct pvrdma_dev;
73 75
74struct pvrdma_page_dir {76struct 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
858 dev->dsr->resp_slot_dma = (u64)slot_dma;858 dev->dsr->resp_slot_dma = (u64)slot_dma;
859 859
860 /* Async event ring */860 /* Async event ring */
861 dev->dsr->async_ring_pages.num_pages = 4;861 dev->dsr->async_ring_pages.num_pages = PVRDMA_NUM_RING_PAGES;
862 ret = pvrdma_page_dir_init(dev, &dev->async_pdir,862 ret = pvrdma_page_dir_init(dev, &dev->async_pdir,
863 dev->dsr->async_ring_pages.num_pages, true);863 dev->dsr->async_ring_pages.num_pages, true);
864 if (ret)864 if (ret)
@@ -867,7 +867,7 @@ static int pvrdma_pci_probe(struct pci_dev *pdev, · 2 unmodified lines
867 dev->dsr->async_ring_pages.pdir_dma = dev->async_pdir.dir_dma;867 dev->dsr->async_ring_pages.pdir_dma = dev->async_pdir.dir_dma;
868 868
869 /* CQ notification ring */869 /* CQ notification ring */
870 dev->dsr->cq_ring_pages.num_pages = 4;870 dev->dsr->cq_ring_pages.num_pages = PVRDMA_NUM_RING_PAGES;
871 ret = pvrdma_page_dir_init(dev, &dev->cq_pdir,871 ret = pvrdma_page_dir_init(dev, &dev->cq_pdir,
872 dev->dsr->cq_ring_pages.num_pages, true);872 dev->dsr->cq_ring_pages.num_pages, true);
873 if (ret)873 if (ret)
drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c+13−20
@@ -554,13 +554,13 @@ out: · 553 unmodified lines
554 return ret;554 return ret;
555}555}
556 556
557static inline void *get_sq_wqe(struct pvrdma_qp *qp, int n)557static inline void *get_sq_wqe(struct pvrdma_qp *qp, unsigned int n)
558{558{
559 return pvrdma_page_dir_get_ptr(&qp->pdir,559 return pvrdma_page_dir_get_ptr(&qp->pdir,
560 qp->sq.offset + n * qp->sq.wqe_size);560 qp->sq.offset + n * qp->sq.wqe_size);
561}561}
562 562
563static inline void *get_rq_wqe(struct pvrdma_qp *qp, int n)563static inline void *get_rq_wqe(struct pvrdma_qp *qp, unsigned int n)
564{564{
565 return pvrdma_page_dir_get_ptr(&qp->pdir,565 return pvrdma_page_dir_get_ptr(&qp->pdir,
566 qp->rq.offset + n * qp->rq.wqe_size);566 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
598 unsigned long flags;598 unsigned long flags;
599 struct pvrdma_sq_wqe_hdr *wqe_hdr;599 struct pvrdma_sq_wqe_hdr *wqe_hdr;
600 struct pvrdma_sge *sge;600 struct pvrdma_sge *sge;
601 int i, index;601 int i, ret;
602 int nreq;
603 int ret;
604 602
605 /*603 /*
606 * In states lower than RTS, we can fail immediately. In other states,604 * 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
613 611
614 spin_lock_irqsave(&qp->sq.lock, flags);612 spin_lock_irqsave(&qp->sq.lock, flags);
615 613
616 index = pvrdma_idx(&qp->sq.ring->prod_tail, qp->sq.wqe_cnt);614 while (wr) {
617 for (nreq = 0; wr; nreq++, wr = wr->next) {615 unsigned int tail = 0;
618 unsigned int tail;
619 616
620 if (unlikely(!pvrdma_idx_ring_has_space(617 if (unlikely(!pvrdma_idx_ring_has_space(
621 qp->sq.ring, qp->sq.wqe_cnt, &tail))) {618 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
680 }677 }
681 }678 }
682 679
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);
684 memset(wqe_hdr, 0, sizeof(*wqe_hdr));681 memset(wqe_hdr, 0, sizeof(*wqe_hdr));
685 wqe_hdr->wr_id = wr->wr_id;682 wqe_hdr->wr_id = wr->wr_id;
686 wqe_hdr->num_sge = wr->num_sge;683 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
771 /* Make sure wqe is written before index update */768 /* Make sure wqe is written before index update */
772 smp_wmb();769 smp_wmb();
773 770
774 index++;
775 if (unlikely(index >= qp->sq.wqe_cnt))
776 index = 0;
777 /* Update shared sq ring */771 /* Update shared sq ring */
778 pvrdma_idx_ring_inc(&qp->sq.ring->prod_tail,772 pvrdma_idx_ring_inc(&qp->sq.ring->prod_tail,
779 qp->sq.wqe_cnt);773 qp->sq.wqe_cnt);
774
775 wr = wr->next;
780 }776 }
781 777
782 ret = 0;778 ret = 0;
@@ -806,7 +802,6 @@ int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, · 23 unmodified lines
806 struct pvrdma_qp *qp = to_vqp(ibqp);802 struct pvrdma_qp *qp = to_vqp(ibqp);
807 struct pvrdma_rq_wqe_hdr *wqe_hdr;803 struct pvrdma_rq_wqe_hdr *wqe_hdr;
808 struct pvrdma_sge *sge;804 struct pvrdma_sge *sge;
809 int index, nreq;
810 int ret = 0;805 int ret = 0;
811 int i;806 int i;
812 807
@@ -821,9 +816,8 @@ int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, · 8 unmodified lines
821 816
822 spin_lock_irqsave(&qp->rq.lock, flags);817 spin_lock_irqsave(&qp->rq.lock, flags);
823 818
824 index = pvrdma_idx(&qp->rq.ring->prod_tail, qp->rq.wqe_cnt);819 while (wr) {
825 for (nreq = 0; wr; nreq++, wr = wr->next) {820 unsigned int tail = 0;
826 unsigned int tail;
827 821
828 if (unlikely(wr->num_sge > qp->rq.max_sg ||822 if (unlikely(wr->num_sge > qp->rq.max_sg ||
829 wr->num_sge < 0)) {823 wr->num_sge < 0)) {
@@ -843,7 +837,7 @@ int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, · 13 unmodified lines
843 goto out;837 goto out;
844 }838 }
845 839
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);
847 wqe_hdr->wr_id = wr->wr_id;841 wqe_hdr->wr_id = wr->wr_id;
848 wqe_hdr->num_sge = wr->num_sge;842 wqe_hdr->num_sge = wr->num_sge;
849 wqe_hdr->total_len = 0;843 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
859 /* Make sure wqe is written before index update */853 /* Make sure wqe is written before index update */
860 smp_wmb();854 smp_wmb();
861 855
862 index++;
863 if (unlikely(index >= qp->rq.wqe_cnt))
864 index = 0;
865 /* Update shared rq ring */856 /* Update shared rq ring */
866 pvrdma_idx_ring_inc(&qp->rq.ring->prod_tail,857 pvrdma_idx_ring_inc(&qp->rq.ring->prod_tail,
867 qp->rq.wqe_cnt);858 qp->rq.wqe_cnt);
859
860 wr = wr->next;
868 }861 }
869 862
870 spin_unlock_irqrestore(&qp->rq.lock, flags);863 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