hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/infiniband/sw/rxe/rxe_resp.c
....@@ -1,34 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
12 /*
23 * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
34 * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
4
- *
5
- * This software is available to you under a choice of one of two
6
- * licenses. You may choose to be licensed under the terms of the GNU
7
- * General Public License (GPL) Version 2, available from the file
8
- * COPYING in the main directory of this source tree, or the
9
- * OpenIB.org BSD license below:
10
- *
11
- * Redistribution and use in source and binary forms, with or
12
- * without modification, are permitted provided that the following
13
- * conditions are met:
14
- *
15
- * - Redistributions of source code must retain the above
16
- * copyright notice, this list of conditions and the following
17
- * disclaimer.
18
- *
19
- * - Redistributions in binary form must reproduce the above
20
- * copyright notice, this list of conditions and the following
21
- * disclaimer in the documentation and/or other materials
22
- * provided with the distribution.
23
- *
24
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
- * SOFTWARE.
325 */
336
347 #include <linux/skbuff.h>
....@@ -104,8 +77,7 @@
10477 };
10578
10679 /* rxe_recv calls here to add a request packet to the input queue */
107
-void rxe_resp_queue_pkt(struct rxe_dev *rxe, struct rxe_qp *qp,
108
- struct sk_buff *skb)
80
+void rxe_resp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb)
10981 {
11082 int must_sched;
11183 struct rxe_pkt_info *pkt = SKB_TO_PKT(skb);
....@@ -124,12 +96,9 @@
12496 struct sk_buff *skb;
12597
12698 if (qp->resp.state == QP_STATE_ERROR) {
127
- skb = skb_dequeue(&qp->req_pkts);
128
- if (skb) {
129
- /* drain request packet queue */
99
+ while ((skb = skb_dequeue(&qp->req_pkts))) {
130100 rxe_drop_ref(qp);
131101 kfree_skb(skb);
132
- return RESPST_GET_REQ;
133102 }
134103
135104 /* go drain recv wr queue */
....@@ -638,7 +607,7 @@
638607 if (ack->mask & RXE_ATMACK_MASK)
639608 atmack_set_orig(ack, qp->resp.atomic_orig);
640609
641
- err = rxe_prepare(rxe, ack, skb, &crc);
610
+ err = rxe_prepare(ack, skb, &crc);
642611 if (err) {
643612 kfree_skb(skb);
644613 return NULL;
....@@ -661,7 +630,6 @@
661630 static enum resp_states read_reply(struct rxe_qp *qp,
662631 struct rxe_pkt_info *req_pkt)
663632 {
664
- struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
665633 struct rxe_pkt_info ack_pkt;
666634 struct sk_buff *skb;
667635 int mtu = qp->mtu;
....@@ -747,7 +715,7 @@
747715 p = payload_addr(&ack_pkt) + payload + bth_pad(&ack_pkt);
748716 *p = ~icrc;
749717
750
- err = rxe_xmit_packet(rxe, qp, &ack_pkt, skb);
718
+ err = rxe_xmit_packet(qp, &ack_pkt, skb);
751719 if (err) {
752720 pr_err("Failed sending RDMA reply.\n");
753721 return RESPST_ERR_RNR;
....@@ -846,6 +814,7 @@
846814 struct ib_wc *wc = &cqe.ibwc;
847815 struct ib_uverbs_wc *uwc = &cqe.uibwc;
848816 struct rxe_recv_wqe *wqe = qp->resp.wqe;
817
+ struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
849818
850819 if (unlikely(!wqe))
851820 return RESPST_CLEANUP;
....@@ -863,6 +832,7 @@
863832 }
864833
865834 if (wc->status == IB_WC_SUCCESS) {
835
+ rxe_counter_inc(rxe, RXE_CNT_RDMA_RECV);
866836 wc->opcode = (pkt->mask & RXE_IMMDT_MASK &&
867837 pkt->mask & RXE_WRITE_MASK) ?
868838 IB_WC_RECV_RDMA_WITH_IMM : IB_WC_RECV;
....@@ -913,7 +883,6 @@
913883 }
914884
915885 if (pkt->mask & RXE_IETH_MASK) {
916
- struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
917886 struct rxe_mem *rmr;
918887
919888 wc->wc_flags |= IB_WC_WITH_INVALIDATE;
....@@ -965,7 +934,6 @@
965934 int err = 0;
966935 struct rxe_pkt_info ack_pkt;
967936 struct sk_buff *skb;
968
- struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
969937
970938 skb = prepare_ack_packet(qp, pkt, &ack_pkt, IB_OPCODE_RC_ACKNOWLEDGE,
971939 0, psn, syndrome, NULL);
....@@ -974,7 +942,7 @@
974942 goto err1;
975943 }
976944
977
- err = rxe_xmit_packet(rxe, qp, &ack_pkt, skb);
945
+ err = rxe_xmit_packet(qp, &ack_pkt, skb);
978946 if (err)
979947 pr_err_ratelimited("Failed sending ack\n");
980948
....@@ -988,7 +956,6 @@
988956 int rc = 0;
989957 struct rxe_pkt_info ack_pkt;
990958 struct sk_buff *skb;
991
- struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
992959 struct resp_res *res;
993960
994961 skb = prepare_ack_packet(qp, pkt, &ack_pkt,
....@@ -1014,7 +981,7 @@
1014981 res->last_psn = ack_pkt.psn;
1015982 res->cur_psn = ack_pkt.psn;
1016983
1017
- rc = rxe_xmit_packet(rxe, qp, &ack_pkt, skb);
984
+ rc = rxe_xmit_packet(qp, &ack_pkt, skb);
1018985 if (rc) {
1019986 pr_err_ratelimited("Failed sending ack\n");
1020987 rxe_drop_ref(qp);
....@@ -1144,8 +1111,7 @@
11441111 if (res) {
11451112 skb_get(res->atomic.skb);
11461113 /* Resend the result. */
1147
- rc = rxe_xmit_packet(to_rdev(qp->ibqp.device), qp,
1148
- pkt, res->atomic.skb);
1114
+ rc = rxe_xmit_packet(qp, pkt, res->atomic.skb);
11491115 if (rc) {
11501116 pr_err("Failed resending result. This flow is not handled - skb ignored\n");
11511117 rc = RESPST_CLEANUP;