Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3431191imu; Sun, 11 Nov 2018 14:58:03 -0800 (PST) X-Google-Smtp-Source: AJdET5dLIhaF/KfSLv9k4fdv013Fk3oUgY2h+1v8acpTa3iPac8Il4yi365ApYv/9RmV6cmy76JO X-Received: by 2002:a62:c20b:: with SMTP id l11-v6mr18223508pfg.251.1541977082988; Sun, 11 Nov 2018 14:58:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977082; cv=none; d=google.com; s=arc-20160816; b=Wu+GssseIvx+egnV4LN7iNEMGFaEAwo3+oNHgZYuWgPoP10pkiXYgWWNokrN0wZZ1P xqGz1AT88mRP3wJ+55fMseOLZRD1QS4EjCnxgd5AwL1I7NiQD9cw6dgWxnEMOTChN81k x3O9R8Z0P9aUNNaXe3lDRzIJEEV095bTvgQnZxT5KSDwfsg/qh+YSihpp9zVfL8flsQj FgQSJKAB5Yxh6ItB0ozURRmHWQxKuz2vmTmcFUZ6aO6Ksg+lQl/MH/jkyF/DkHJGeHmt AMZzcA9vWylNhI4RCKqo2T8Mllu7OBemqvsOV8zqgT974AuArVGsOiGIks3bxmA3eMFK HR/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Kky2QWIDcSpg91R2x88T8EdaZUAkfqe4l+FAUOrbPiA=; b=ozjMMSDtp7StCR0sxgc1r852pRIbN/bThfZF4ZCHNcGliW3szvjB2b3oKWl0AYnJEP 1EWkTuovmsn0sFF9PWaeZw1S6wCL6jcdcD1T5RgUsNTVeufJ6Byy3HIeMiUxiqoYpusq 7IZevL++14OadEgzo/EHMf9TfM0otIkKX/gpJ3hU2xLJu/g78dfgqrIoOKU3HSUitW7U e7d3FZG4FKD5u8+0Q6MT2WptXr67sl8HDbSUONbsx/gVAsBZtih6d6pfdmdRqCVIQf/c LuH9zuBU34Is65pwN6JtIOXkf8aXqRQKV5I2JFItxDMYaa3JAfQDCDUdb66g8oGD8zLG XRiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nSB2nFCZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u6si14250737pgl.561.2018.11.11.14.57.48; Sun, 11 Nov 2018 14:58:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nSB2nFCZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390831AbeKLIWr (ORCPT + 99 others); Mon, 12 Nov 2018 03:22:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:54352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403841AbeKLIWq (ORCPT ); Mon, 12 Nov 2018 03:22:46 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A4E1022353; Sun, 11 Nov 2018 22:32:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975568; bh=6w4aKS/s/TBeLRIrE+1322nL9/ny+ZOt3sEU/d16VaU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nSB2nFCZ8IzdSGaLIHF8VbmBlKLluA5qhF78RkGZI/z5iatfBsSISzBVZmpsLymLZ zMRNWoMK444kc2pgbG32X/hyQSiSjF4lTm3hpzbupO+3oTw5KXPbhppaLPk/Ml1IDh rVQ5jCRTSiUYVLg0YkJgqHT+T0rYfnRcjIlz7OW0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vijay Immanuel , Doug Ledford , Sasha Levin Subject: [PATCH 4.14 107/222] IB/rxe: fix for duplicate request processing and ack psns Date: Sun, 11 Nov 2018 14:23:24 -0800 Message-Id: <20181111221657.411739735@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vijay Immanuel [ Upstream commit b97db58557f4aa6d9903f8e1deea6b3d1ed0ba43 ] Don't reset the resp opcode for a replayed read response. The resp opcode could be in the middle of a write or send sequence, when the duplicate read request was received. An example sequence is as follows: - Receive read request for 12KB PSN 20. Transmit read response first, middle and last with PSNs 20,21,22. - Receive write first PSN 23. At this point the resp psn is 24 and resp opcode is write first. - The sender notices that PSN 20 is dropped and retransmits. Receive read request for 12KB PSN 20. Transmit read response first, middle and last with PSNs 20,21,22. The resp opcode is set to -1, the resp psn remains 24. - Receive write first PSN 23. This is processed by duplicate_request(). The resp opcode remains -1 and resp psn remains 24. - Receive write middle PSN 24. check_op_seq() reports a missing first error since the resp opcode is -1. When sending an ack for a duplicate send or write request, use the psn of the previous ack sent. Do not use the psn of a read response for the ack. An example sequence is as follows: - Receive write PSN 30. Transmit ACK for PSN 30. - Receive read request 4KB PSN 31. Transmit read response with PSN 31. The resp psn is now 32. - The sender notices that PSN 30 is dropped and retransmits. Receive write PSN 30. duplicate_request() sends an ACK with PSN 31. That is incorrect since PSN 31 was a read request. Signed-off-by: Vijay Immanuel Signed-off-by: Doug Ledford Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/sw/rxe/rxe_resp.c | 8 ++++++-- drivers/infiniband/sw/rxe/rxe_verbs.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) --- a/drivers/infiniband/sw/rxe/rxe_resp.c +++ b/drivers/infiniband/sw/rxe/rxe_resp.c @@ -683,6 +683,7 @@ static enum resp_states read_reply(struc rxe_advance_resp_resource(qp); res->type = RXE_READ_MASK; + res->replay = 0; res->read.va = qp->resp.va; res->read.va_org = qp->resp.va; @@ -753,7 +754,8 @@ static enum resp_states read_reply(struc state = RESPST_DONE; } else { qp->resp.res = NULL; - qp->resp.opcode = -1; + if (!res->replay) + qp->resp.opcode = -1; if (psn_compare(res->cur_psn, qp->resp.psn) >= 0) qp->resp.psn = res->cur_psn; state = RESPST_CLEANUP; @@ -815,6 +817,7 @@ static enum resp_states execute(struct r /* next expected psn, read handles this separately */ qp->resp.psn = (pkt->psn + 1) & BTH_PSN_MASK; + qp->resp.ack_psn = qp->resp.psn; qp->resp.opcode = pkt->opcode; qp->resp.status = IB_WC_SUCCESS; @@ -1071,7 +1074,7 @@ static enum resp_states duplicate_reques struct rxe_pkt_info *pkt) { enum resp_states rc; - u32 prev_psn = (qp->resp.psn - 1) & BTH_PSN_MASK; + u32 prev_psn = (qp->resp.ack_psn - 1) & BTH_PSN_MASK; if (pkt->mask & RXE_SEND_MASK || pkt->mask & RXE_WRITE_MASK) { @@ -1114,6 +1117,7 @@ static enum resp_states duplicate_reques res->state = (pkt->psn == res->first_psn) ? rdatm_res_state_new : rdatm_res_state_replay; + res->replay = 1; /* Reset the resource, except length. */ res->read.va_org = iova; --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -173,6 +173,7 @@ enum rdatm_res_state { struct resp_res { int type; + int replay; u32 first_psn; u32 last_psn; u32 cur_psn; @@ -197,6 +198,7 @@ struct rxe_resp_info { enum rxe_qp_state state; u32 msn; u32 psn; + u32 ack_psn; int opcode; int drop_msg; int goto_error;