From patchwork Mon Oct 2 08:23:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalderon, Michal" X-Patchwork-Id: 9980393 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 851C56029B for ; Mon, 2 Oct 2017 08:25:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7738728952 for ; Mon, 2 Oct 2017 08:25:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6BD7028955; Mon, 2 Oct 2017 08:25:46 +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 3F44C28952 for ; Mon, 2 Oct 2017 08:25:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751082AbdJBIZi (ORCPT ); Mon, 2 Oct 2017 04:25:38 -0400 Received: from mail-sn1nam01on0054.outbound.protection.outlook.com ([104.47.32.54]:53908 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750962AbdJBIZf (ORCPT ); Mon, 2 Oct 2017 04:25:35 -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=hzfj72xSCOJPSTeZLdjhgpZ0DYWSYPIbarupUtwPJAkTbngPNkogdGGcpqpl6FNOGMULbXLPp1gl6h5xHgRQingeG2T5bg3kbOBBPUplPd92zWfmm075r6RTVVa+S1j5r1vPjUkg49MQJNPDBfP1WzTm+1hLajYNKGBxYY0nxXk= Received: from CY1PR07CA0034.namprd07.prod.outlook.com (10.166.202.44) by SN1PR0701MB2095.namprd07.prod.outlook.com (10.163.132.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Mon, 2 Oct 2017 08:25:34 +0000 Received: from BL2FFO11FD015.protection.gbl (2a01:111:f400:7c09::100) by CY1PR07CA0034.outlook.office365.com (2a01:111:e400:c60a::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.11 via Frontend Transport; Mon, 2 Oct 2017 08:25:34 +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 BL2FFO11FD015.mail.protection.outlook.com (10.173.160.223) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.56.11 via Frontend Transport; Mon, 2 Oct 2017 08:25:32 +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; Mon, 2 Oct 2017 01:25:30 -0700 From: Michal Kalderon To: CC: , , , Michal Kalderon , "Ariel Elior" Subject: [PATCH net-next 10/12] qed: Add support for freeing two ll2 buffers for corner cases Date: Mon, 2 Oct 2017 11:23:56 +0300 Message-ID: <1506932638-26268-11-git-send-email-Michal.Kalderon@cavium.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1506932638-26268-1-git-send-email-Michal.Kalderon@cavium.com> References: <1506932638-26268-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)(50466002)(16586007)(316002)(104016004)(50226002)(2351001)(105586002)(106466001)(5660300001)(48376002)(6916009)(2950100002)(81166006)(81156014)(107886003)(77096006)(5003940100001)(6666003)(8676002)(54906003)(8936002)(47776003)(72206003)(4326008)(478600001)(36756003)(189998001)(76176999)(305945005)(356003)(2906002)(86362001)(50986999)(69596002)(101416001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0701MB2095; 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; BL2FFO11FD015; 1:ArsUwlceVDII2cE6t+mvaSfss16e9vrcnPGw/aTngEtd6f1JceVG/cZtaaTAy2pL6rXM199i9lRCoNxqfZch8V+9yxsPaxyDAYlqHF47VPdgirRM8hDKGf62KwC5syAE X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 579ade20-e518-469b-96a7-08d5096f2656 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:SN1PR0701MB2095; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB2095; 3:YyC7mazEe15FTV7gfNbtqjEYepd6vOgJHiavPj9fSk6Sjxyd7ursXAGJecAZkc7Orm3OT7W2QY8SdnItwTflWtcfLPRN9I/6uw76l0fih+0NGBkgkYMqbndKGxnQl72Yo5Dy2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B7voaumQzFAilM4Re57eJeN/rJ9GVxLs1KWj7IgSXy/GifyZP6q0l04nM6E+I9MjAxbJN8fQOxFtX1pZrNnokb+O+yAtHTTOba98PkyXU2whGVPbnuG3/u0t3PMyzAKFKqPYCFXjbgB5oEa5wFIWbT9uG2FRpKGOfd4WweZhfTqVxkaFxBdWy3LR8VMSFzDwRkK9dvgL4w0/PhZgMXBJrMIKqxefl9lCDZsIUojDiLGQVwKOu7FLtwjAYPAHQngK8KLkiMXETj6GNDCY7YS8K5FoMG1tdhEYUZk; 4:H0JoXzEbFNI6gNUfT2MJ9M6YKPF1OHonTVF2VghuzFwu10pd8sgHEMwVlSR1UVJnwattfzvc0z4yvq4VmyUP7sx/fRFDOYxI0gaWNOYI5Tc13gmSy3EKeIgykHngCarJYN+BDaWW60lo28WE2Br3J76v2UeF1B3FcJtuJkYbS9Dn3WZ1ngy9nH/YzWooYYLQI5aeywAQHIwr6pv4tjzW2tbMqYZlqd3uDkJFmM73fjX8K+Jo9pU6bkCYSO0HS6e9 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)(5005006)(8121501046)(3002001)(10201501046)(100000703101)(100105400095)(93006095)(93001095)(6041248)(20161123555025)(20161123558100)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR0701MB2095; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR0701MB2095; X-Forefront-PRVS: 0448A97BF2 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0701MB2095; 23:5BG5LGUW/O+KNDqV5Dzk75kKLq0xl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iagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2017 08:25:32.8745 (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: SN1PR0701MB2095 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;