| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. |
|---|
| 3 | 4 | * 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. |
|---|
| 32 | 5 | */ |
|---|
| 33 | 6 | |
|---|
| 34 | 7 | #include <linux/skbuff.h> |
|---|
| .. | .. |
|---|
| 104 | 77 | }; |
|---|
| 105 | 78 | |
|---|
| 106 | 79 | /* 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) |
|---|
| 109 | 81 | { |
|---|
| 110 | 82 | int must_sched; |
|---|
| 111 | 83 | struct rxe_pkt_info *pkt = SKB_TO_PKT(skb); |
|---|
| .. | .. |
|---|
| 124 | 96 | struct sk_buff *skb; |
|---|
| 125 | 97 | |
|---|
| 126 | 98 | 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))) { |
|---|
| 130 | 100 | rxe_drop_ref(qp); |
|---|
| 131 | 101 | kfree_skb(skb); |
|---|
| 132 | | - return RESPST_GET_REQ; |
|---|
| 133 | 102 | } |
|---|
| 134 | 103 | |
|---|
| 135 | 104 | /* go drain recv wr queue */ |
|---|
| .. | .. |
|---|
| 638 | 607 | if (ack->mask & RXE_ATMACK_MASK) |
|---|
| 639 | 608 | atmack_set_orig(ack, qp->resp.atomic_orig); |
|---|
| 640 | 609 | |
|---|
| 641 | | - err = rxe_prepare(rxe, ack, skb, &crc); |
|---|
| 610 | + err = rxe_prepare(ack, skb, &crc); |
|---|
| 642 | 611 | if (err) { |
|---|
| 643 | 612 | kfree_skb(skb); |
|---|
| 644 | 613 | return NULL; |
|---|
| .. | .. |
|---|
| 661 | 630 | static enum resp_states read_reply(struct rxe_qp *qp, |
|---|
| 662 | 631 | struct rxe_pkt_info *req_pkt) |
|---|
| 663 | 632 | { |
|---|
| 664 | | - struct rxe_dev *rxe = to_rdev(qp->ibqp.device); |
|---|
| 665 | 633 | struct rxe_pkt_info ack_pkt; |
|---|
| 666 | 634 | struct sk_buff *skb; |
|---|
| 667 | 635 | int mtu = qp->mtu; |
|---|
| .. | .. |
|---|
| 747 | 715 | p = payload_addr(&ack_pkt) + payload + bth_pad(&ack_pkt); |
|---|
| 748 | 716 | *p = ~icrc; |
|---|
| 749 | 717 | |
|---|
| 750 | | - err = rxe_xmit_packet(rxe, qp, &ack_pkt, skb); |
|---|
| 718 | + err = rxe_xmit_packet(qp, &ack_pkt, skb); |
|---|
| 751 | 719 | if (err) { |
|---|
| 752 | 720 | pr_err("Failed sending RDMA reply.\n"); |
|---|
| 753 | 721 | return RESPST_ERR_RNR; |
|---|
| .. | .. |
|---|
| 846 | 814 | struct ib_wc *wc = &cqe.ibwc; |
|---|
| 847 | 815 | struct ib_uverbs_wc *uwc = &cqe.uibwc; |
|---|
| 848 | 816 | struct rxe_recv_wqe *wqe = qp->resp.wqe; |
|---|
| 817 | + struct rxe_dev *rxe = to_rdev(qp->ibqp.device); |
|---|
| 849 | 818 | |
|---|
| 850 | 819 | if (unlikely(!wqe)) |
|---|
| 851 | 820 | return RESPST_CLEANUP; |
|---|
| .. | .. |
|---|
| 863 | 832 | } |
|---|
| 864 | 833 | |
|---|
| 865 | 834 | if (wc->status == IB_WC_SUCCESS) { |
|---|
| 835 | + rxe_counter_inc(rxe, RXE_CNT_RDMA_RECV); |
|---|
| 866 | 836 | wc->opcode = (pkt->mask & RXE_IMMDT_MASK && |
|---|
| 867 | 837 | pkt->mask & RXE_WRITE_MASK) ? |
|---|
| 868 | 838 | IB_WC_RECV_RDMA_WITH_IMM : IB_WC_RECV; |
|---|
| .. | .. |
|---|
| 913 | 883 | } |
|---|
| 914 | 884 | |
|---|
| 915 | 885 | if (pkt->mask & RXE_IETH_MASK) { |
|---|
| 916 | | - struct rxe_dev *rxe = to_rdev(qp->ibqp.device); |
|---|
| 917 | 886 | struct rxe_mem *rmr; |
|---|
| 918 | 887 | |
|---|
| 919 | 888 | wc->wc_flags |= IB_WC_WITH_INVALIDATE; |
|---|
| .. | .. |
|---|
| 965 | 934 | int err = 0; |
|---|
| 966 | 935 | struct rxe_pkt_info ack_pkt; |
|---|
| 967 | 936 | struct sk_buff *skb; |
|---|
| 968 | | - struct rxe_dev *rxe = to_rdev(qp->ibqp.device); |
|---|
| 969 | 937 | |
|---|
| 970 | 938 | skb = prepare_ack_packet(qp, pkt, &ack_pkt, IB_OPCODE_RC_ACKNOWLEDGE, |
|---|
| 971 | 939 | 0, psn, syndrome, NULL); |
|---|
| .. | .. |
|---|
| 974 | 942 | goto err1; |
|---|
| 975 | 943 | } |
|---|
| 976 | 944 | |
|---|
| 977 | | - err = rxe_xmit_packet(rxe, qp, &ack_pkt, skb); |
|---|
| 945 | + err = rxe_xmit_packet(qp, &ack_pkt, skb); |
|---|
| 978 | 946 | if (err) |
|---|
| 979 | 947 | pr_err_ratelimited("Failed sending ack\n"); |
|---|
| 980 | 948 | |
|---|
| .. | .. |
|---|
| 988 | 956 | int rc = 0; |
|---|
| 989 | 957 | struct rxe_pkt_info ack_pkt; |
|---|
| 990 | 958 | struct sk_buff *skb; |
|---|
| 991 | | - struct rxe_dev *rxe = to_rdev(qp->ibqp.device); |
|---|
| 992 | 959 | struct resp_res *res; |
|---|
| 993 | 960 | |
|---|
| 994 | 961 | skb = prepare_ack_packet(qp, pkt, &ack_pkt, |
|---|
| .. | .. |
|---|
| 1014 | 981 | res->last_psn = ack_pkt.psn; |
|---|
| 1015 | 982 | res->cur_psn = ack_pkt.psn; |
|---|
| 1016 | 983 | |
|---|
| 1017 | | - rc = rxe_xmit_packet(rxe, qp, &ack_pkt, skb); |
|---|
| 984 | + rc = rxe_xmit_packet(qp, &ack_pkt, skb); |
|---|
| 1018 | 985 | if (rc) { |
|---|
| 1019 | 986 | pr_err_ratelimited("Failed sending ack\n"); |
|---|
| 1020 | 987 | rxe_drop_ref(qp); |
|---|
| .. | .. |
|---|
| 1144 | 1111 | if (res) { |
|---|
| 1145 | 1112 | skb_get(res->atomic.skb); |
|---|
| 1146 | 1113 | /* 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); |
|---|
| 1149 | 1115 | if (rc) { |
|---|
| 1150 | 1116 | pr_err("Failed resending result. This flow is not handled - skb ignored\n"); |
|---|
| 1151 | 1117 | rc = RESPST_CLEANUP; |
|---|