diff options
author | Roland Dreier <rolandd@cisco.com> | 2007-07-18 14:30:34 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2007-07-18 14:30:34 -0400 |
commit | 80885456e844552044c8c5f1f9bf0f6773b187ea (patch) | |
tree | 350fd53a7ef9fadd94a21aa1d282296dc787d2a6 /drivers/infiniband | |
parent | 7f5eb9bb8c7fb3bd411674b856872d7ab4a7b1a3 (diff) |
IB/mthca: Factor out setting WQE data segment entries
Factor code to set data segment entries out of the work request
posting functions into inline functions mthca_set_data_seg() and
mthca_set_data_seg_inval(). This makes the code more readable and
also allows the compiler to do a better job -- on x86_64:
add/remove: 0/0 grow/shrink: 0/6 up/down: 0/-69 (-69)
function old new delta
mthca_arbel_post_srq_recv 373 369 -4
mthca_arbel_post_receive 570 562 -8
mthca_tavor_post_srq_recv 520 508 -12
mthca_tavor_post_send 1344 1330 -14
mthca_arbel_post_send 1481 1467 -14
mthca_tavor_post_receive 792 775 -17
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_qp.c | 41 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_srq.c | 28 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_wqe.h | 15 |
3 files changed, 30 insertions, 54 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index 0e9ef24f6638..2548250a822d 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c | |||
@@ -1740,13 +1740,8 @@ int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
1740 | } | 1740 | } |
1741 | 1741 | ||
1742 | for (i = 0; i < wr->num_sge; ++i) { | 1742 | for (i = 0; i < wr->num_sge; ++i) { |
1743 | ((struct mthca_data_seg *) wqe)->byte_count = | 1743 | mthca_set_data_seg(wqe, wr->sg_list + i); |
1744 | cpu_to_be32(wr->sg_list[i].length); | 1744 | wqe += sizeof (struct mthca_data_seg); |
1745 | ((struct mthca_data_seg *) wqe)->lkey = | ||
1746 | cpu_to_be32(wr->sg_list[i].lkey); | ||
1747 | ((struct mthca_data_seg *) wqe)->addr = | ||
1748 | cpu_to_be64(wr->sg_list[i].addr); | ||
1749 | wqe += sizeof (struct mthca_data_seg); | ||
1750 | size += sizeof (struct mthca_data_seg) / 16; | 1745 | size += sizeof (struct mthca_data_seg) / 16; |
1751 | } | 1746 | } |
1752 | 1747 | ||
@@ -1869,13 +1864,8 @@ int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr, | |||
1869 | } | 1864 | } |
1870 | 1865 | ||
1871 | for (i = 0; i < wr->num_sge; ++i) { | 1866 | for (i = 0; i < wr->num_sge; ++i) { |
1872 | ((struct mthca_data_seg *) wqe)->byte_count = | 1867 | mthca_set_data_seg(wqe, wr->sg_list + i); |
1873 | cpu_to_be32(wr->sg_list[i].length); | 1868 | wqe += sizeof (struct mthca_data_seg); |
1874 | ((struct mthca_data_seg *) wqe)->lkey = | ||
1875 | cpu_to_be32(wr->sg_list[i].lkey); | ||
1876 | ((struct mthca_data_seg *) wqe)->addr = | ||
1877 | cpu_to_be64(wr->sg_list[i].addr); | ||
1878 | wqe += sizeof (struct mthca_data_seg); | ||
1879 | size += sizeof (struct mthca_data_seg) / 16; | 1869 | size += sizeof (struct mthca_data_seg) / 16; |
1880 | } | 1870 | } |
1881 | 1871 | ||
@@ -2125,13 +2115,8 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
2125 | } | 2115 | } |
2126 | 2116 | ||
2127 | for (i = 0; i < wr->num_sge; ++i) { | 2117 | for (i = 0; i < wr->num_sge; ++i) { |
2128 | ((struct mthca_data_seg *) wqe)->byte_count = | 2118 | mthca_set_data_seg(wqe, wr->sg_list + i); |
2129 | cpu_to_be32(wr->sg_list[i].length); | 2119 | wqe += sizeof (struct mthca_data_seg); |
2130 | ((struct mthca_data_seg *) wqe)->lkey = | ||
2131 | cpu_to_be32(wr->sg_list[i].lkey); | ||
2132 | ((struct mthca_data_seg *) wqe)->addr = | ||
2133 | cpu_to_be64(wr->sg_list[i].addr); | ||
2134 | wqe += sizeof (struct mthca_data_seg); | ||
2135 | size += sizeof (struct mthca_data_seg) / 16; | 2120 | size += sizeof (struct mthca_data_seg) / 16; |
2136 | } | 2121 | } |
2137 | 2122 | ||
@@ -2253,20 +2238,12 @@ int mthca_arbel_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr, | |||
2253 | } | 2238 | } |
2254 | 2239 | ||
2255 | for (i = 0; i < wr->num_sge; ++i) { | 2240 | for (i = 0; i < wr->num_sge; ++i) { |
2256 | ((struct mthca_data_seg *) wqe)->byte_count = | 2241 | mthca_set_data_seg(wqe, wr->sg_list + i); |
2257 | cpu_to_be32(wr->sg_list[i].length); | ||
2258 | ((struct mthca_data_seg *) wqe)->lkey = | ||
2259 | cpu_to_be32(wr->sg_list[i].lkey); | ||
2260 | ((struct mthca_data_seg *) wqe)->addr = | ||
2261 | cpu_to_be64(wr->sg_list[i].addr); | ||
2262 | wqe += sizeof (struct mthca_data_seg); | 2242 | wqe += sizeof (struct mthca_data_seg); |
2263 | } | 2243 | } |
2264 | 2244 | ||
2265 | if (i < qp->rq.max_gs) { | 2245 | if (i < qp->rq.max_gs) |
2266 | ((struct mthca_data_seg *) wqe)->byte_count = 0; | 2246 | mthca_set_data_seg_inval(wqe); |
2267 | ((struct mthca_data_seg *) wqe)->lkey = cpu_to_be32(MTHCA_INVAL_LKEY); | ||
2268 | ((struct mthca_data_seg *) wqe)->addr = 0; | ||
2269 | } | ||
2270 | 2247 | ||
2271 | qp->wrid[ind] = wr->wr_id; | 2248 | qp->wrid[ind] = wr->wr_id; |
2272 | 2249 | ||
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c index b8f05a526673..88d219e730ad 100644 --- a/drivers/infiniband/hw/mthca/mthca_srq.c +++ b/drivers/infiniband/hw/mthca/mthca_srq.c | |||
@@ -543,20 +543,12 @@ int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr, | |||
543 | } | 543 | } |
544 | 544 | ||
545 | for (i = 0; i < wr->num_sge; ++i) { | 545 | for (i = 0; i < wr->num_sge; ++i) { |
546 | ((struct mthca_data_seg *) wqe)->byte_count = | 546 | mthca_set_data_seg(wqe, wr->sg_list + i); |
547 | cpu_to_be32(wr->sg_list[i].length); | ||
548 | ((struct mthca_data_seg *) wqe)->lkey = | ||
549 | cpu_to_be32(wr->sg_list[i].lkey); | ||
550 | ((struct mthca_data_seg *) wqe)->addr = | ||
551 | cpu_to_be64(wr->sg_list[i].addr); | ||
552 | wqe += sizeof (struct mthca_data_seg); | 547 | wqe += sizeof (struct mthca_data_seg); |
553 | } | 548 | } |
554 | 549 | ||
555 | if (i < srq->max_gs) { | 550 | if (i < srq->max_gs) |
556 | ((struct mthca_data_seg *) wqe)->byte_count = 0; | 551 | mthca_set_data_seg_inval(wqe); |
557 | ((struct mthca_data_seg *) wqe)->lkey = cpu_to_be32(MTHCA_INVAL_LKEY); | ||
558 | ((struct mthca_data_seg *) wqe)->addr = 0; | ||
559 | } | ||
560 | 552 | ||
561 | ((struct mthca_next_seg *) prev_wqe)->nda_op = | 553 | ((struct mthca_next_seg *) prev_wqe)->nda_op = |
562 | cpu_to_be32((ind << srq->wqe_shift) | 1); | 554 | cpu_to_be32((ind << srq->wqe_shift) | 1); |
@@ -662,20 +654,12 @@ int mthca_arbel_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr, | |||
662 | } | 654 | } |
663 | 655 | ||
664 | for (i = 0; i < wr->num_sge; ++i) { | 656 | for (i = 0; i < wr->num_sge; ++i) { |
665 | ((struct mthca_data_seg *) wqe)->byte_count = | 657 | mthca_set_data_seg(wqe, wr->sg_list + i); |
666 | cpu_to_be32(wr->sg_list[i].length); | ||
667 | ((struct mthca_data_seg *) wqe)->lkey = | ||
668 | cpu_to_be32(wr->sg_list[i].lkey); | ||
669 | ((struct mthca_data_seg *) wqe)->addr = | ||
670 | cpu_to_be64(wr->sg_list[i].addr); | ||
671 | wqe += sizeof (struct mthca_data_seg); | 658 | wqe += sizeof (struct mthca_data_seg); |
672 | } | 659 | } |
673 | 660 | ||
674 | if (i < srq->max_gs) { | 661 | if (i < srq->max_gs) |
675 | ((struct mthca_data_seg *) wqe)->byte_count = 0; | 662 | mthca_set_data_seg_inval(wqe); |
676 | ((struct mthca_data_seg *) wqe)->lkey = cpu_to_be32(MTHCA_INVAL_LKEY); | ||
677 | ((struct mthca_data_seg *) wqe)->addr = 0; | ||
678 | } | ||
679 | 663 | ||
680 | srq->wrid[ind] = wr->wr_id; | 664 | srq->wrid[ind] = wr->wr_id; |
681 | srq->first_free = next_ind; | 665 | srq->first_free = next_ind; |
diff --git a/drivers/infiniband/hw/mthca/mthca_wqe.h b/drivers/infiniband/hw/mthca/mthca_wqe.h index e7d2c1e86199..f6a66fe78e48 100644 --- a/drivers/infiniband/hw/mthca/mthca_wqe.h +++ b/drivers/infiniband/hw/mthca/mthca_wqe.h | |||
@@ -113,4 +113,19 @@ struct mthca_mlx_seg { | |||
113 | __be16 vcrc; | 113 | __be16 vcrc; |
114 | }; | 114 | }; |
115 | 115 | ||
116 | static __always_inline void mthca_set_data_seg(struct mthca_data_seg *dseg, | ||
117 | struct ib_sge *sg) | ||
118 | { | ||
119 | dseg->byte_count = cpu_to_be32(sg->length); | ||
120 | dseg->lkey = cpu_to_be32(sg->lkey); | ||
121 | dseg->addr = cpu_to_be64(sg->addr); | ||
122 | } | ||
123 | |||
124 | static __always_inline void mthca_set_data_seg_inval(struct mthca_data_seg *dseg) | ||
125 | { | ||
126 | dseg->byte_count = 0; | ||
127 | dseg->lkey = cpu_to_be32(MTHCA_INVAL_LKEY); | ||
128 | dseg->addr = 0; | ||
129 | } | ||
130 | |||
116 | #endif /* MTHCA_WQE_H */ | 131 | #endif /* MTHCA_WQE_H */ |