From patchwork Mon Sep 18 22:21:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13390529 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F01531A7E for ; Mon, 18 Sep 2023 22:22:02 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2079.outbound.protection.outlook.com [40.107.94.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49F99BE for ; Mon, 18 Sep 2023 15:22:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bkoHOg2GyjSlrHTaPrIhASxZ3k5LbziZrZGaix147bqA4zvoFMM8pbWa6hcTdk0z3OWW8Fe81VOiK4uJOTwhwKVae6ZJBXogGVx6eqh1pMg/dM5nldTWkCgpPtqWNeHOO/N6dxfYK4g1zqJl6etgXqaCA/wTcZtOb61lFSbz3+cUiD65mUB5etLWYilEMtIi+KAHxK7hHi/qN+AvhOkwAVRtheDNjsmeaS3MTRHH7L6Z5V395pa03575Hlp4ud6e38lnjcM+/iSswOzEHec87iZWM6QQIzpyx+zotiVilEV53QT6M/6Ry7v8uqnuvdzR87eYtAwtemptuxXs/VSE9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dkJOjoIQT+LzvLymrZxwrHuYwDcuApNpSxGe+3YQsPI=; b=C3Y+OxeVJhLebPYo2DDkWAWniYrs53PpaT2y8s76CC+3khao/7UUH9DhPTcr6DGTGyRNa7bbqkuHVw+do3Zm8x7gEUkpG27kPr7ps0VZwtCgR/KgoUS0/nXyTkSv43ri1IEm/DYd5s6cK0EF1v7XhkZTkClF/Gxv+6zVBFmD0dDGETw0eHjKB3HpO3DVS6KOSyENjtUROvD0YayKmImo9OmwIsnR8NUpJrjEhLZf0GsooCijVlDbnkyWvaUhj44R8cjMuTbRkZQa5GW5//B3UDu5yNQ0U+8edoeRyuyhTuy55dJZSdUKM11ekWfrrSdRw/x4VdKoPtum0bC4TatV7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dkJOjoIQT+LzvLymrZxwrHuYwDcuApNpSxGe+3YQsPI=; b=UskAOQcbC6BR46qY6RcliQJx/QvGpr1iFLVbpKO4L5Jv+W4sO7ALALgGQB9KSk+edle1dIRjcRaejkzhy5zg21+YwYaDVtuJgqw0FaWMS6GWED7AzsBDq/ltzhzDYMApHHyK82sdRDBCbNQkTN7z1rnooTioUCr54AZeAOqph9w= Received: from MN2PR15CA0015.namprd15.prod.outlook.com (2603:10b6:208:1b4::28) by PH7PR12MB6979.namprd12.prod.outlook.com (2603:10b6:510:1b9::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep 2023 22:21:56 +0000 Received: from BL6PEPF0001AB57.namprd02.prod.outlook.com (2603:10b6:208:1b4:cafe::66) by MN2PR15CA0015.outlook.office365.com (2603:10b6:208:1b4::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 22:21:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB57.mail.protection.outlook.com (10.167.241.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.20 via Frontend Transport; Mon, 18 Sep 2023 22:21:56 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 18 Sep 2023 17:21:55 -0500 From: Shannon Nelson To: , , , CC: , , Shannon Nelson Subject: [PATCH net-next 1/3] ionic: count SGs in packet to minimize linearize Date: Mon, 18 Sep 2023 15:21:34 -0700 Message-ID: <20230918222136.40251-2-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230918222136.40251-1-shannon.nelson@amd.com> References: <20230918222136.40251-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB57:EE_|PH7PR12MB6979:EE_ X-MS-Office365-Filtering-Correlation-Id: e3acb21d-76aa-49ea-beb5-08dbb895ab66 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 63WSmpzpcktCxO8qLukVCf4XutmzlwI6N3cu82fGWoUO+52xVHUxsPJMTpjvukV2SyRfY1UbBY1rnqruprG4E9XfcbKMJw1dkF7FCfrxae7HOGbRnTf4rocB5Mm3BS9Lrkw82DWNwbr2J4SOJmszE12QhwIwObX0uPhp54F65x8f/y5Bo/W4TKudf0lfdDX/lUzQERs+RNT7oxk8sNxV9XwOsdrfX/m0+01yI6esnk2XdglUqbsQ8IddzJ06gqH7hd0xqkpqId2Td67qYOaeUTE2qCNzerrpQdJy9FOZISksZ2NlaHYzCJG8UhZ+w81f3uomj7MBC6vPDraojCMDvedPYl6NWIa1OWfci8RQunyB5Y1Ol2QowYs6DkpFyyvNdlq0KIAgbMRBzvUjfJ+p9G2bTZDoPO/1gN0bcgIgvqQzIU6h6BE+eewFtTYmwH1D5eN2ZsN+tVF48U9Qmlm4wID4CQ6CavVh/aoEiCjVyBuRgYzQGq+rwfPlmPTSSs37qT5QMYV+BYraCC8veR2dwU1ssxeLlTmKb2JEIH9qme7ZY3eeWmvkOEor1bLOGdE6q07IkouAiIAN7dS4gJUs2K8mxGEjan/W88ZMrAGSkIYl9Ov4D03XiPmUNygITB1yzkf9YASYcvCRLvGj6qpT+Pb6eDG0+jQP8/Ak6rv6mPEXcDoVrdZUxzzJtm5KpvjFWTE3VKIT793N94XynckR9en0kN+oZaznjvBHpWg0E3y1WP2sSz+XQSpLUP2rZpXXyhfhc/rHnRiYy6CdNmpV1w== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(346002)(39860400002)(396003)(376002)(82310400011)(1800799009)(186009)(451199024)(36840700001)(46966006)(40470700004)(356005)(81166007)(26005)(16526019)(82740400003)(2616005)(8936002)(8676002)(1076003)(4326008)(40460700003)(83380400001)(36860700001)(2906002)(36756003)(47076005)(426003)(336012)(40480700001)(5660300002)(44832011)(86362001)(478600001)(6666004)(316002)(54906003)(70206006)(70586007)(110136005)(41300700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 22:21:56.7863 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3acb21d-76aa-49ea-beb5-08dbb895ab66 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB57.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6979 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org There are some cases where an skb carries more frags than the number of SGs that ionic can support per descriptor - this forces the driver to linearize the skb. However, if this is a TSO packet that is going to become multiple descriptors (one per MTU-sized packet) and spread the frags across them, this time-consuming linearization is likely not necessary. We scan the frag list and count up the number of SGs that would be created for each descriptor that would be generated, and only linearize if we hit the SG limit on a descriptor. In most cases, we won't even get to the frag list scan, so this doesn't affect typical traffic. Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_txrx.c | 77 ++++++++++++++++--- 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index 26798fc635db..c08a61323066 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -1239,25 +1239,84 @@ static int ionic_tx(struct ionic_queue *q, struct sk_buff *skb) static int ionic_tx_descs_needed(struct ionic_queue *q, struct sk_buff *skb) { struct ionic_tx_stats *stats = q_to_tx_stats(q); + bool too_many_frags = false; + skb_frag_t *frag; + int desc_bufs; + int chunk_len; + int frag_rem; + int tso_rem; + int seg_rem; + bool encap; + int hdrlen; int ndescs; int err; /* Each desc is mss long max, so a descriptor for each gso_seg */ - if (skb_is_gso(skb)) + if (skb_is_gso(skb)) { ndescs = skb_shinfo(skb)->gso_segs; - else + } else { ndescs = 1; + if (skb_shinfo(skb)->nr_frags > q->max_sg_elems) { + too_many_frags = true; + goto linearize; + } + } - /* If non-TSO, just need 1 desc and nr_frags sg elems */ - if (skb_shinfo(skb)->nr_frags <= q->max_sg_elems) + /* If non-TSO, or no frags to check, we're done */ + if (!skb_is_gso(skb) || !skb_shinfo(skb)->nr_frags) return ndescs; - /* Too many frags, so linearize */ - err = skb_linearize(skb); - if (err) - return err; + /* We need to scan the skb to be sure that none of the MTU sized + * packets in the TSO will require more sgs per descriptor than we + * can support. We loop through the frags, add up the lengths for + * a packet, and count the number of sgs used per packet. + */ + tso_rem = skb->len; + frag = skb_shinfo(skb)->frags; + encap = skb->encapsulation; + + /* start with just hdr in first part of first descriptor */ + if (encap) + hdrlen = skb_inner_tcp_all_headers(skb); + else + hdrlen = skb_tcp_all_headers(skb); + seg_rem = min_t(int, tso_rem, hdrlen + skb_shinfo(skb)->gso_size); + frag_rem = hdrlen; + + while (tso_rem > 0) { + desc_bufs = 0; + while (seg_rem > 0) { + desc_bufs++; + + /* We add the +1 because we can take buffers for one + * more than we have SGs: one for the initial desc data + * in addition to the SG segments that might follow. + */ + if (desc_bufs > q->max_sg_elems + 1) { + too_many_frags = true; + goto linearize; + } + + if (frag_rem == 0) { + frag_rem = skb_frag_size(frag); + frag++; + } + chunk_len = min(frag_rem, seg_rem); + frag_rem -= chunk_len; + tso_rem -= chunk_len; + seg_rem -= chunk_len; + } + + seg_rem = min_t(int, tso_rem, skb_shinfo(skb)->gso_size); + } - stats->linearize++; +linearize: + if (too_many_frags) { + err = skb_linearize(skb); + if (err) + return err; + stats->linearize++; + } return ndescs; } From patchwork Mon Sep 18 22:21:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13390527 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B015450EB for ; Mon, 18 Sep 2023 22:22:01 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2081.outbound.protection.outlook.com [40.107.244.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DFD9B0 for ; Mon, 18 Sep 2023 15:22:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ELrkEAlWTqL7m6nwO0tAfBLuEzEXNVIy2L46Er4sm22K38sDpr08e+GnGamhau0q3RluCtLgU9oodAxdsBPhrIKcR9iT8gy42aNeElg1grZ5JhRHQibwhk9TZLhemei5O/lRUSGiy1uI5RjVxsJDqfu0HFjMkQx8/UzgT3UiIYQFuglDjETS/HX3bPzqsx9mQ2Q5Q7Ww9dB4eu3NtfCIWKuP+QxkiQj9RvUH7F79EtnBdk5sIY/GBYtS6gcQyyWJeUBB/A8y17H4ozEbgdvvdyhs7Dq3ZeBlLUX77yDYpCaJlwNMjRSSgKfSJN3xR9zPjNfxAseuKdBtWRNtcu2S0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=g6ZFstsRJnJ1vQDEOd8lFEn+xyYW7eT80+CEpd6TjVo=; b=XuTOBVLzsyogl9vxX0xzifIbEJybLV4Zm9otcztAUrNPzTNiD/LCOdslRkcqqWIfy9TWHq2qmTemp3YO28aCAwnNtaOsoz/lTnKSRw/E5+ksDmpjbADtUpjQ2qiMANgqwDCQ2Py+T38Uhv+aMGAn/PqCjpjw2bsuaa7fBLht1Hl6WfM1du4Ug6WBcJ7dOX1YEpRJ6gzm6Op1yBjhndu6grw+zDNGnxM9f8MAfWqcAzE7jSPnyXeb7z1XUuaPMddLtKTQtL66sYmCrGdf5zr7Mc74r0N0hM6111XqKmtqSnmoVMBvv4UUZITAovOzA12njkvTuCXMLIsOnHBOeYnMLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g6ZFstsRJnJ1vQDEOd8lFEn+xyYW7eT80+CEpd6TjVo=; b=LLsDmeWasacmgb0T+n9Y1suA+xM6YH70dItAzFy0t708MJGAWDyDdJ+NkSm2xM9P5zcmHt74ZT7qGwBQ2BUhfhMe/oKsHuT5EO3ORavDawE8ixsMEti2ZEsm+3JoyEfT4XBDl/FXRxpltv8rKAl+b24ejH2K1yLRpbMibzf97Go= Received: from MN2PR14CA0013.namprd14.prod.outlook.com (2603:10b6:208:23e::18) by SA0PR12MB4399.namprd12.prod.outlook.com (2603:10b6:806:98::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Mon, 18 Sep 2023 22:21:58 +0000 Received: from BL6PEPF0001AB55.namprd02.prod.outlook.com (2603:10b6:208:23e:cafe::76) by MN2PR14CA0013.outlook.office365.com (2603:10b6:208:23e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26 via Frontend Transport; Mon, 18 Sep 2023 22:21:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB55.mail.protection.outlook.com (10.167.241.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.19 via Frontend Transport; Mon, 18 Sep 2023 22:21:57 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 18 Sep 2023 17:21:56 -0500 From: Shannon Nelson To: , , , CC: , , Shannon Nelson Subject: [PATCH net-next 2/3] ionic: add a check for max SGs and SKB frags Date: Mon, 18 Sep 2023 15:21:35 -0700 Message-ID: <20230918222136.40251-3-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230918222136.40251-1-shannon.nelson@amd.com> References: <20230918222136.40251-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB55:EE_|SA0PR12MB4399:EE_ X-MS-Office365-Filtering-Correlation-Id: 841c0b20-acb2-4c77-ad92-08dbb895abe6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MAmWLF992GZlx8qEkSZEO0LQ3QxdZ7DpKP/rIuQ3FMtVxNXe9cNDpKl12K6GXoIBUS7yc9W4Yir+Ctu+jJhjsqDMkCWbU+imTEE0ttKahrqNONrnSZo/kiTwd5XIySK4uly3iiCHFEFev1UkQZNESIy1boeDUHIR/qgPF/P17g40E0QQXWb5JwU2M5kThh4MlXes04UmaO1S+dxSDjX3IvQlsCZpSqUiF+fKJ67dHgYrK4jFtqiL/NZEdguBmCBo4KKL8cId6e6x80q1Zv7Ab92SKXBDxR3k3CySkdNlUCso23pKo9lHT2NTuF5KiV1A/oH6msakjg3oaYAQxyFU6TPui0iYZEq5wD7o6walf6jErs//p5GGnfYvBBLdw0Pa4R/nv4J/uKOROaJ5naeKht4PVsV6paAE704l4IrT83kKLbALc6Y+APy9T3BZcBbAKrF7wIh3mfyDuCPmsv1IpZdjExKll8EsZlMoBmDCRX5Tf4ewoGQmgkflNkPHIBB8THqHyqwevLs6qwapdUFiTJcne4m4FEaRf6ZaQyJ0PM/gcT41XL+b+eY8oqWUy0pXJQpxqTFqjk/w/MgDKVka5T7OQ4sZdoyEvOVXU0+HC2T/O4ZJDFEUY7Ip8/BNWnjh2B1IRtsOPDpKK/MqmA4OkNjIm2YqDGh/At/cBGo0scBvNSb0DxtD9h419yhjZtuvVfsv7Z+oGbXq59VilEbIQ2pq3sgDKSz1oAW8DYJm+hVnoC0xAEFkAx6CyzUfvpBeT0bZj4bBJM0s7aasscia+w== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(39860400002)(346002)(376002)(396003)(1800799009)(451199024)(82310400011)(186009)(40470700004)(46966006)(36840700001)(4326008)(2906002)(8936002)(8676002)(316002)(41300700001)(16526019)(426003)(1076003)(26005)(336012)(40480700001)(478600001)(110136005)(70586007)(70206006)(54906003)(44832011)(5660300002)(40460700003)(36756003)(36860700001)(47076005)(2616005)(83380400001)(6666004)(356005)(81166007)(86362001)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 22:21:57.6247 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 841c0b20-acb2-4c77-ad92-08dbb895abe6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB55.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4399 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add a check of the queue's max_sg_elems against the maximum frags we expect to see per SKB and take the smaller of the two as our max for the queues' descriptor buffer allocations. Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index 2c3e36b2dd7f..edc14730ce88 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -3831,6 +3831,18 @@ static void ionic_lif_queue_identify(struct ionic_lif *lif) qtype, qti->max_sg_elems); dev_dbg(ionic->dev, " qtype[%d].sg_desc_stride = %d\n", qtype, qti->sg_desc_stride); + + if (qti->max_sg_elems >= IONIC_MAX_FRAGS) { + qti->max_sg_elems = IONIC_MAX_FRAGS - 1; + dev_dbg(ionic->dev, "limiting qtype %d max_sg_elems to IONIC_MAX_FRAGS-1 %d\n", + qtype, qti->max_sg_elems); + } + + if (qti->max_sg_elems > MAX_SKB_FRAGS) { + qti->max_sg_elems = MAX_SKB_FRAGS; + dev_dbg(ionic->dev, "limiting qtype %d max_sg_elems to MAX_SKB_FRAGS %d\n", + qtype, qti->max_sg_elems); + } } } From patchwork Mon Sep 18 22:21:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13390528 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 214B8328C5 for ; Mon, 18 Sep 2023 22:22:02 +0000 (UTC) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2040.outbound.protection.outlook.com [40.107.220.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0D90BC for ; Mon, 18 Sep 2023 15:22:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O5xLZ2QjP8jEPjDBz2SFTY1zoJcpN7qlyS/73/pDvYVHKi/yf+eqVoPaSTAXhY4aT+2DdwjGATi1knSo47EG4QtVBUe2yTXOH9B9+CyjP3uEM/2PcypdKwqf36XbOMb7jrLR9dFSxIONpHcI+YYLbbEiZ+4x3m8hMiYkCR7jjnfvoPUfV1+CRdt52FAX53qaBsQtASlT6hK66pdANqn99+HeuBSCy4URF2kvFxYV/Yhv51MYZVd6ALXNSsR1csO/sb5ERWaAbA5h+nrVrGRlLAOsBw604W2TOkRrRAs2YHrs4QHPP/BbNFfi1Z/wIRDGKVXqGv7xfJWKh2bfoV4M/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XHq9duAalZcU0Rn3n8vpMhj7je2hvyzr98EshXXOGnY=; b=K9CiP2/Utl/78HFqMHbSI7S8tcDpiDc8JZXYxrGg5LVQVuZ/VxRyfU8JJcjdIF1vu7hffFrBa48yX+g2Gk3aiy/CqdPxzoXz9r6H51oDFigWLwEH7RtMkqIC13d5qhlT6Rgx4RRHVp/WUQdGg8byAfr9blbrSJ3qlkkSqkqbEEv2lC3PZWr9KeYWJ3W7IbLjMEW8G8eeXQxHO1mvcdZxFKEHLNsLpIQ6eRJAhEsBqX6jL/9hJSl3bVw0n3HvZzyT1hSvgyr5USOwycO+PkIThRGihhHGRyrFqiCF2BkSxOSHrUEIaI4zlGzMMLGUIzbF7dhXBGdxYSM/VN+yRz8NKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XHq9duAalZcU0Rn3n8vpMhj7je2hvyzr98EshXXOGnY=; b=Yf1Mwb/blAvWgn+36mTOh+rWgnjK47X+NL7rO5JJPVDgTATblDqdWhXBRFH6ZCbYFTe6QDbxNVBC6TA6tvUOEXAVEuhX35zSpEG0ZmtRcmsIDD3fPA7ny9NeOimE0ols2OI49wSizpmA3jQOBTA6VZD/NPl0ypPHK8/LOKgKWrg= Received: from MN2PR15CA0029.namprd15.prod.outlook.com (2603:10b6:208:1b4::42) by MW4PR12MB7287.namprd12.prod.outlook.com (2603:10b6:303:22c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.33; Mon, 18 Sep 2023 22:21:59 +0000 Received: from BL6PEPF0001AB52.namprd02.prod.outlook.com (2603:10b6:208:1b4:cafe::17) by MN2PR15CA0029.outlook.office365.com (2603:10b6:208:1b4::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 22:21:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB52.mail.protection.outlook.com (10.167.241.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.20 via Frontend Transport; Mon, 18 Sep 2023 22:21:58 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 18 Sep 2023 17:21:57 -0500 From: Shannon Nelson To: , , , CC: , , Shannon Nelson Subject: [PATCH net-next 3/3] ionic: expand the descriptor bufs array Date: Mon, 18 Sep 2023 15:21:36 -0700 Message-ID: <20230918222136.40251-4-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230918222136.40251-1-shannon.nelson@amd.com> References: <20230918222136.40251-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB52:EE_|MW4PR12MB7287:EE_ X-MS-Office365-Filtering-Correlation-Id: 99fdc4cc-4a84-43aa-ccff-08dbb895ac55 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iMdoMlM3Sy9iTie3gi5tYNe5S92ORsO4XbOdllb1qR/UKoh3Zdem5nBz+WAqEpvRLDF34xsyBciu38Sqw/B/VrtubDi36r0tI52L001VFmDBywe81sez0aaAyu8TDoth2t9t4Ad5e5WdNy0BhLzcnfZtms9dqX3HRWpGTES5TAqYSBKVFzq8LRgX5pJTYn0F9NwrpbPjpCyS0T6jmfmn1QiDmcm62nwU2MSUHhwJBwgJu/HyicJ31CjYJYRTep7lfMy/mUD1yH0vHDkfYVuctHjpoBRVvvXatsrgiwmUJqocLer8zo2ZnGt8XemcVm+pC1bHTIdN1ySzva0kIaFUDVxOyCcBE6FJtSQRkM2vS4QXj7vP8LzGR2BQbZP1lTzKQAwMY4OJmOiuibttSLdKQ2wwIlpF5nz0pJPsKi6hdIS0aKPhxlPK0GvL8K6i1wzp8Kc5r+8TzSKrBhAD5RBfipkCtUBcC39+JlhTE4LW4Cz8n+bhdhhg6QRGF2Af4SKFWFATRKHYNl1R9LBceDRmlsBYsw5Aqp432roq7u8Ff3naeTInrkkou2nbg49iK6R+TJRyf5Br9yeZDUsuowO6QL80Q/qoHQHirm+2FGdHXAUFGCykO3iPNrK52Ij0gG9KbTC7tBypypWM8CZVrbmV0n/ZV9pVXl4lsDKVr1ibhV1l8g6OtLbEILjfepbFVs1Jyi9PKxX+8BhJDIs7ktGTOFTt1de3HN2pdoVS5QKG+rlCFL65KjRhnbNEi886J48Z99KIr/Igy9vJSLZ89IY3pA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(376002)(39860400002)(396003)(346002)(136003)(186009)(1800799009)(451199024)(82310400011)(40470700004)(36840700001)(46966006)(26005)(54906003)(316002)(70586007)(110136005)(70206006)(336012)(1076003)(36756003)(2616005)(83380400001)(6666004)(82740400003)(36860700001)(356005)(86362001)(40480700001)(478600001)(40460700003)(16526019)(81166007)(2906002)(426003)(47076005)(5660300002)(41300700001)(4326008)(8676002)(44832011)(8936002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 22:21:58.3530 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 99fdc4cc-4a84-43aa-ccff-08dbb895ac55 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB52.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7287 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org When processing a TSO we may have frags spread across several descriptors, and the total count of frags in one skb may exceed our per descriptor IONIC_MAX_FRAGS: this is fine as long as each descriptor has fewer frags than the limit. Since the skb could have as many as MAX_SKB_FRAGS, and the first descriptor is where we track and map the frag buffers, we need to be sure we can map buffers for all of the frags plus the TSO header in the first descriptor's buffer array. Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_dev.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.h b/drivers/net/ethernet/pensando/ionic/ionic_dev.h index 6aac98bcb9f4..b51febf86504 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "ionic_if.h" #include "ionic_regs.h" @@ -216,7 +217,7 @@ struct ionic_desc_info { }; unsigned int bytes; unsigned int nbufs; - struct ionic_buf_info bufs[IONIC_MAX_FRAGS]; + struct ionic_buf_info bufs[MAX_SKB_FRAGS + 1]; ionic_desc_cb cb; void *cb_arg; };