From patchwork Tue Oct 3 08:55:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalderon, Michal" X-Patchwork-Id: 9981953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DEB396029B for ; Tue, 3 Oct 2017 08:56:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D151E1FFCA for ; Tue, 3 Oct 2017 08:56:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C62CE2862A; Tue, 3 Oct 2017 08:56:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E8811FFCA for ; Tue, 3 Oct 2017 08:56:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751486AbdJCI40 (ORCPT ); Tue, 3 Oct 2017 04:56:26 -0400 Received: from mail-by2nam01on0052.outbound.protection.outlook.com ([104.47.34.52]:41056 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751277AbdJCI4W (ORCPT ); Tue, 3 Oct 2017 04:56:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=S+uJLfRqh4xBDEbeBWqrK+Wzyy4BG1Zk/pzRqlU/8Uw=; b=AtNUeuHJiamV7g5n1+EUqruMPsjCPuyxQVgdhyjF0/TuHVfhaRhYEXbbGL3vH/QEVuXjkwSx5KfvQZziVOGRCmza4EZWg9w0M79J1ZLjr3gexwBvpKBuhylhluCYp7U2qWJv2nnl/HK2moPKAW0z223Wg/19HnVYBFjP9j7IBsE= Received: from SN4PR0701CA0019.namprd07.prod.outlook.com (10.161.192.157) by BY2PR0701MB2037.namprd07.prod.outlook.com (10.163.156.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Tue, 3 Oct 2017 08:56:20 +0000 Received: from BY2FFO11FD019.protection.gbl (2a01:111:f400:7c0c::112) by SN4PR0701CA0019.outlook.office365.com (2603:10b6:803:28::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.9 via Frontend Transport; Tue, 3 Oct 2017 08:56:20 +0000 Authentication-Results: spf=none (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=cavium.com; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BY2FFO11FD019.mail.protection.outlook.com (10.1.14.107) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.77.10 via Frontend Transport; Tue, 3 Oct 2017 08:56:20 +0000 Received: from lb-tlvb-michal.il.qlogic.com.com (10.185.6.89) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.347.0; Tue, 3 Oct 2017 01:56:18 -0700 From: Michal Kalderon To: CC: , , , Michal Kalderon , "Ariel Elior" Subject: [PATCH v2 net-next 10/12] qed: Add support for freeing two ll2 buffers for corner cases Date: Tue, 3 Oct 2017 11:55:00 +0300 Message-ID: <1507020902-4952-11-git-send-email-Michal.Kalderon@cavium.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1507020902-4952-1-git-send-email-Michal.Kalderon@cavium.com> References: <1507020902-4952-1-git-send-email-Michal.Kalderon@cavium.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:50.232.66.26; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(346002)(376002)(2980300002)(428002)(189002)(199003)(54906003)(2351001)(101416001)(5003940100001)(189998001)(72206003)(48376002)(50466002)(6666003)(2950100002)(36756003)(6916009)(104016004)(69596002)(50986999)(50226002)(316002)(76176999)(16586007)(478600001)(5660300001)(107886003)(8936002)(105586002)(86362001)(356003)(2906002)(47776003)(106466001)(81166006)(8676002)(81156014)(305945005)(4326008)(77096006); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0701MB2037; H:CAEXCH02.caveonetworks.com; FPR:; SPF:None; PTR:50-232-66-26-static.hfc.comcastbusiness.net; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD019; 1:BlIq4iUnXxPpSpvFiAimx8/39M4Vfi5rPmCqfbHfeD4ESzyp7qD7NOlGsZwi5uU+sXzgG8CR1FZ37FVsxHgSPHb9AAsqw31WrtH37SsT16i22/RdlM2rfeczhZcrGW2W X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b2b0463b-0528-42a9-9a76-08d50a3c9dac X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:BY2PR0701MB2037; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0701MB2037; 3:fot0TImeH1MSf4OMezpNgMJ84Up7wwPV0Ao0aGiOa9Lua+IslVXavXio9K6nnphc+UkeTWuDJTNN+oWE0O42NvZeqCKrpKHRmhhs+kp4k1KsNnhu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IyfeZNMF/4QljbFlkvnDhS46xLPC1wkb3N7yAao94Lkx8o54mMyaa16SFOejw6ZJ67pOwU6zXcUPfHcIquYqKRXQzsDwH+YHBeOarV0vFnyckRc5Kv5g5EtfWr1WGr0xF6ywx6R12El3k15UpSLjzt3OdKwMdbhccxnq3IIG7wxG0O0drQHaMS6dRlKB+lBWEDl6gASIb4rJgM3INj6/NhCY1uqo7D6lBWaxPv0Joo4G5FjndWQeDO8BIu4Bb4BU/ds2HloTE5Civ/n/2mTaQ7HxcBJDmmHFh9ID8K72zCywTtF4IS+/LGCv8k0i+Zl6QeU7L; 4:a6ZnLD+rEV4toNDSJrCOvbk4pYG4zeUmkuD75Eb0yv78LZT/E8oe45zhME89H5w3vICZMGUHIiQk54p+CNY5Dj0emZVnIX1Q6p2BH9wprljSZMRlUDwtsKfeJLArjbqydquGcdq7zO4kjXINFist7150ue9YxgicKDLsj15GDyt1BxRtzJTGe9OwP6vsxmQJUlInqIoc19lLpR3HhBhyWS+Mc8lu8tfdjymZysnmUnxjuykhVm/V6OZYUkqiVexH X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BY2PR0701MB2037; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BY2PR0701MB2037; X-Forefront-PRVS: 044968D9E1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0701MB2037; 23:cCmM6e7pbex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adata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2017 08:56:20.0259 (UTC) X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=711e4ccf-2e9b-4bcf-a551-4094005b6194; Ip=[50.232.66.26]; Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0701MB2037 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When posting a packet on the ll2 tx, we can provide a cookie that will be returned upon tx completion. This cookie is the ll2 iwarp buffer which is then reposted to the rx ring. Part of the unaligned mpa flow is determining when a buffer can be reposted. Each buffer needs to be sent only once as a cookie for on the tx ring. In packed fpdu case, only the last packet will be sent with the buffer, meaning we need to handle the case that a cookie can be NULL on tx complete. In addition, when a fpdu splits over two buffers, but there are no more fpdus on the second buffer, two buffers need to be provided as a cookie. To avoid changing the ll2 interface to provide two cookies, we introduce a piggy buf pointer, relevant for iWARP only, that holds a pointer to a second buffer that needs to be released during tx completion. Signed-off-by: Michal Kalderon Signed-off-by: Ariel Elior --- drivers/net/ethernet/qlogic/qed/qed_iwarp.c | 25 +++++++++++++++++++++++++ drivers/net/ethernet/qlogic/qed/qed_iwarp.h | 1 + 2 files changed, 26 insertions(+) diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c index 83b147f..8b17369 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c +++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c @@ -1846,6 +1846,12 @@ enum qed_iwarp_mpa_pkt_type { /* vlan overload with enum iwarp_ll2_tx_queues */ tx_pkt.vlan = IWARP_LL2_ALIGNED_TX_QUEUE; + /* special case of unaligned packet and not packed, need to send + * both buffers as cookie to release. + */ + if (tcp_payload_size == fpdu->incomplete_bytes) + fpdu->mpa_buf->piggy_buf = buf; + ll2_handle = p_hwfn->p_rdma_info->iwarp.ll2_mpa_handle; /* Set first fragment to header */ @@ -2195,9 +2201,19 @@ static void qed_iwarp_ll2_comp_tx_pkt(void *cxt, u8 connection_handle, bool b_last_fragment, bool b_last_packet) { struct qed_iwarp_ll2_buff *buffer = cookie; + struct qed_iwarp_ll2_buff *piggy; struct qed_hwfn *p_hwfn = cxt; + if (!buffer) /* can happen in packed mpa unaligned... */ + return; + /* this was originally an rx packet, post it back */ + piggy = buffer->piggy_buf; + if (piggy) { + buffer->piggy_buf = NULL; + qed_iwarp_ll2_post_rx(p_hwfn, piggy, connection_handle); + } + qed_iwarp_ll2_post_rx(p_hwfn, buffer, connection_handle); if (connection_handle == p_hwfn->p_rdma_info->iwarp.ll2_mpa_handle) @@ -2216,6 +2232,15 @@ static void qed_iwarp_ll2_rel_tx_pkt(void *cxt, u8 connection_handle, if (!buffer) return; + if (buffer->piggy_buf) { + dma_free_coherent(&p_hwfn->cdev->pdev->dev, + buffer->piggy_buf->buff_size, + buffer->piggy_buf->data, + buffer->piggy_buf->data_phys_addr); + + kfree(buffer->piggy_buf); + } + dma_free_coherent(&p_hwfn->cdev->pdev->dev, buffer->buff_size, buffer->data, buffer->data_phys_addr); diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.h b/drivers/net/ethernet/qlogic/qed/qed_iwarp.h index 858755c..58db51a 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.h +++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.h @@ -55,6 +55,7 @@ enum qed_iwarp_qp_state { #define QED_IWARP_HANDLE_INVAL (0xff) struct qed_iwarp_ll2_buff { + struct qed_iwarp_ll2_buff *piggy_buf; void *data; dma_addr_t data_phys_addr; u32 buff_size;