From patchwork Mon Oct 24 09:29:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13016948 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84A22ECAAA1 for ; Mon, 24 Oct 2022 09:30:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230187AbiJXJa0 (ORCPT ); Mon, 24 Oct 2022 05:30:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230274AbiJXJaU (ORCPT ); Mon, 24 Oct 2022 05:30:20 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2089.outbound.protection.outlook.com [40.107.237.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41C2642ACB for ; Mon, 24 Oct 2022 02:30:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PPdMKdEZVbCrWJ0N0VeE6Nyw99ujt867J9e3H2llq1jDOMLqur4rG/aVhMJqgwN+6blUZI6OYk+OFzjnDFIVzVAhWsR6+nFaT6wnQBCmuCLod9lS+j41jS5PVspfyPRS0KdiBUbFzyh2SkMoCqWczw1tiL45dE1QYmtGB450MTNW3PzanWlEsCeXToAwdSZphRf7r+LChv3zQDMRDz/i5fHMV9FLgItgXIEqGE65P2PTwNeIpBSsmfa6x5y6vSmqHc2QZKDSxkp8kZITX/XSEEDPbCT5qdHTJNB9I2PkHPzR54PC4SGbcyjjGSWwvEmPC2U34gDDiWaanjcOJpYCkg== 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=uX9yTJVfx243DT4rn/clx3tkrELYka32ZoIkzHfPejg=; b=IVMSzsS81cAU/cqwpnXSjGBcowKFehSbjvWSx6c1G+uG0xoC6mjBJRHfmkd39PEkM4en1hKfo8hL0OFBM4RmtXMycDGovF0KseWjIVsqvvpf1IKPSrTFBEMIE2Pu0ZE4u8s3UfDZOIfTPn7B45TPlRgh/HtQpUlsVa+erOIg5Y4pjVMgPPg9PtBbxWU5PrAO1aqcTh98S0R4aCOGszgjgW1Jly52Xyq+e3lMUBGpIXV7vilTJ3tbpqkT3whUw9arsS09Qi+FpD2Hwz273DFEmP5jr/y27DLWBuKGqh2aGKTRp6+CZbIfqDxmc/Ty9IxzZcWiOCWDpNB6Zm1C50+dMw== 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=uX9yTJVfx243DT4rn/clx3tkrELYka32ZoIkzHfPejg=; b=LAe54f5tw7piFIuRM+l2pr8JtWAVrkNMBfXtaAnJFBXuziTHbGBvgsYKgqYGnBCSapU0L3DO1xzDakiFAKRyUE+X7tM1MtoNvkG8n2kR9VgtX2C3QuprFt1RTPiQZazp8dcgn0By0Lbwtxlhy78ylRkE1pFBkCvnClG2vxQlrFg= Received: from BN9PR03CA0041.namprd03.prod.outlook.com (2603:10b6:408:fb::16) by MN0PR12MB6197.namprd12.prod.outlook.com (2603:10b6:208:3c6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Mon, 24 Oct 2022 09:30:11 +0000 Received: from BN8NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fb:cafe::61) by BN9PR03CA0041.outlook.office365.com (2603:10b6:408:fb::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.26 via Frontend Transport; Mon, 24 Oct 2022 09:30:11 +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 BN8NAM11FT058.mail.protection.outlook.com (10.13.177.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5746.16 via Frontend Transport; Mon, 24 Oct 2022 09:30:11 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.2375.31; Mon, 24 Oct 2022 04:30:10 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 24 Oct 2022 04:30:10 -0500 Received: from xcbecree41x.xilinx.com (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.2375.31 via Frontend Transport; Mon, 24 Oct 2022 04:30:08 -0500 From: To: , CC: , , , , , Edward Cree Subject: [PATCH net-next 1/5] sfc: check recirc_id match caps before MAE offload Date: Mon, 24 Oct 2022 10:29:21 +0100 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT058:EE_|MN0PR12MB6197:EE_ X-MS-Office365-Filtering-Correlation-Id: 16c61920-2fbf-4089-1da7-08dab5a25924 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gm8EzIVUin1/oLZTf7uHBJI5oLrA75s/W1rIwR7sw0L+0cvnu5P6MbIT5A0wk5jqGOInM4Gg2rZirouZlZlqNhiw7awSbU6MxgfLQig2ztKLWcWfVnJ/9I6WcmnlUFiYG70zXiik4wwbsrVjUwVDrQCQC6206uzFuiE67EF2JTGz+PlXbQ6e+K6Jcrh4XlANAven3r3rKkRRcT/hQxqc6Eq7JrQOplky3yMog73MnLHCe8yaJUUZxn6XgTkX9iZwFBjm17hWAyXOJxfRY7c89idKP3kVnIAFj2SG9v2J4NUBMdR/wVLaXf513B07iPADvftJTUoxc8UJlQIbPyISH7oqssu4QNJ0cVUAK6M5SOOiVl6aEPXGFKWR4d/LKhgUGvc0mAp5C3BDdHN+TkQZd4FJ2Zi23ATMA04dmdBKxC60ZmLwl+8o+D3vWqG+jqSvq3BoEdAbu8f+JNM8coFLesjyNFtCNy3Aue35DHCSJBceMIpVpWIzewDgevt69in0uK9SnljozwHhs45ggTCkKsRBARIRau82b0tIGeoGKO90uZqpeBVN2jdfmdfTSivt5esfkap1j7GA9/lsDwOyL/D3fvCeYmTPyEz0bwAuE+zfddawewe+pzTf9wPSvtavomL29PG+9K2Ags1KS0lxiwRCT79BkKPDB+YX5BFqeCYUUUDMLknz85abL6/KeT5OdnEcmdYeoRNGzEku0/4Bc+02p9aDkcsfeWu+GIDgZxPXGLtrW201mEgZFqnxrfEybMKdXTLUEHMfnPvqBmMmG/RRSrdqJdsmDMsBxaB9dA8RKgdi1Y0UMK2vYs5lliiM 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:(13230022)(4636009)(376002)(136003)(396003)(346002)(39860400002)(451199015)(46966006)(40470700004)(36840700001)(36860700001)(82310400005)(478600001)(2906002)(110136005)(54906003)(316002)(70586007)(70206006)(4326008)(8676002)(6666004)(356005)(41300700001)(26005)(8936002)(6636002)(9686003)(5660300002)(81166007)(36756003)(82740400003)(83380400001)(55446002)(40460700003)(186003)(336012)(2876002)(86362001)(426003)(47076005)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2022 09:30:11.0746 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 16c61920-2fbf-4089-1da7-08dab5a25924 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: BN8NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6197 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Offloaded TC rules always match on recirc_id in the MAE, so we should check that the MAE reported support for this match before attempting to insert the rule. Fixes: d902e1a737d4 ("sfc: bare bones TC offload on EF100") Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/mae.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/net/ethernet/sfc/mae.c b/drivers/net/ethernet/sfc/mae.c index 6f472ea0638a..4ceb8c8f5548 100644 --- a/drivers/net/ethernet/sfc/mae.c +++ b/drivers/net/ethernet/sfc/mae.c @@ -250,6 +250,21 @@ static int efx_mae_match_check_cap_typ(u8 support, enum mask_type typ) } } +/* Validate field mask against hardware capabilities. May return from caller */ +#define CHECK(_mcdi, _field) do { \ + enum mask_type typ = classify_mask((const u8 *)&mask->_field, \ + sizeof(mask->_field)); \ + \ + rc = efx_mae_match_check_cap_typ(supported_fields[MAE_FIELD_ ## _mcdi],\ + typ); \ + if (rc) { \ + NL_SET_ERR_MSG_FMT_MOD(extack, \ + "No support for %s mask in field %s", \ + mask_type_name(typ), #_field); \ + return rc; \ + } \ +} while (0) + int efx_mae_match_check_caps(struct efx_nic *efx, const struct efx_tc_match_fields *mask, struct netlink_ext_ack *extack) @@ -269,6 +284,7 @@ int efx_mae_match_check_caps(struct efx_nic *efx, mask_type_name(ingress_port_mask_type)); return rc; } + CHECK(RECIRC_ID, recirc_id); return 0; } From patchwork Mon Oct 24 09:29:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13016949 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2184ECAAA1 for ; Mon, 24 Oct 2022 09:30:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230151AbiJXJao (ORCPT ); Mon, 24 Oct 2022 05:30:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230225AbiJXJaa (ORCPT ); Mon, 24 Oct 2022 05:30:30 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2054.outbound.protection.outlook.com [40.107.244.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3BE0422EA for ; Mon, 24 Oct 2022 02:30:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FZ3UcBOUptpWLwQvP2DwQwkK9RFGTK+gqVy61Mp2s8rvo1h/wrAe+0hvBfkXpgbHenhrc7MrHnyLVsuB/EkI6AkQlWvuy6CM308fiMQSNKOAol1as2CK8Qa74EbrcXsDsAWnh7A/wUXzY9hyWxUF7e98FRRIJTGeyXr4oADzxeRK4iraR6tnOWOtqbnbgkKkZ5fuCVJczjGyNQ8d4E1zwApzcSHDqGD7C0kfwCRmWQObJpH4a5RuRrzYuSb0PvEDKjPx1uOCZ5z56YjRX8JINaodPt1yaVbpuqBnPu357MWC+5RAyjCIQvgKI2WOw+g0pnIDxFr3bEjh1AyXrm3S7w== 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=LZxHy6eKplb8v/O94DvXQNv0FAXFyx6A3GSv752+kYw=; b=TId1uh5Wea70Xn5sv7rAYNMg5HDHASyV7XdQ3+62KwnOwR6p9rfrD5Akn92Oem68aLDo4CgKl24WfuMOFvKmBYQQCysLB/7jyBjKwwxY1U+vFoUrX8vQX/AvteNlrv1llyi5I0MDUOnfinG8M19ANT4b96wyj8dQYpIUhQEHN5HBZImbKDTJtzo0bpi/3jzNB381LF4vDlNtY262RgCNZk9HjnEgInLA1y618sxW8xNsjEv2nUlzTvXDK03mqU28u4iz65bfpamM3op5nVs+ECkp+NakYyOp+Eaf+lozi1bVvRJqJoCcSHhaQsLasTGW3QffRx4FWFAkG21kccqLPA== 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=LZxHy6eKplb8v/O94DvXQNv0FAXFyx6A3GSv752+kYw=; b=oKTdbwpE7xijnmWJWRyZyLIFSgWqDoirMtTXdzKCtdK+hdTR4GDMOqWNgvkewOjZks73k5ES5nVIiOF8+kbQ4seznWpckbGFaQXQ+XoNXMfQHHgTpyIkulG3F0dH3acQrA/qzvq46pjApE0CNjlpqCwfil3pKJgReNnYv88Ff10= Received: from BN9PR03CA0495.namprd03.prod.outlook.com (2603:10b6:408:130::20) by DM6PR12MB4957.namprd12.prod.outlook.com (2603:10b6:5:20d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.31; Mon, 24 Oct 2022 09:30:26 +0000 Received: from BN8NAM11FT111.eop-nam11.prod.protection.outlook.com (2603:10b6:408:130:cafe::2d) by BN9PR03CA0495.outlook.office365.com (2603:10b6:408:130::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.26 via Frontend Transport; Mon, 24 Oct 2022 09:30:26 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT111.mail.protection.outlook.com (10.13.177.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5746.16 via Frontend Transport; Mon, 24 Oct 2022 09:30:26 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 24 Oct 2022 04:30:25 -0500 Received: from xcbecree41x.xilinx.com (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.2375.31 via Frontend Transport; Mon, 24 Oct 2022 04:30:24 -0500 From: To: , CC: , , , , , Edward Cree Subject: [PATCH net-next 2/5] sfc: add Layer 2 matches to ef100 TC offload Date: Mon, 24 Oct 2022 10:29:22 +0100 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT111:EE_|DM6PR12MB4957:EE_ X-MS-Office365-Filtering-Correlation-Id: c411d695-dc05-49fa-1ff2-08dab5a26250 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pk+8Eyj6Tmn3fA05dlLv0K2iD+EZnJw4L2BGHoK+twOgqsFnn+RETNHzvqN564vyXXiGH9VZILoRTyP7w2la+VPXRvghj47vvQCMlZT0aaUbK+R6JZwBRki/AiAUwyA1zDRDjynYGDVNthbDtVl1Hwk8bjsDjUfMZ2rlgXrRllSW1Bh5y0T9R2hmkqNBiO00kMQrZ582chuGaW3jjDzwd4aX+7QAb2Pfz7F71RNpWCyuGNxhzMScYOlgvqmhj5HfEuPx7HOofiT5cgVBVxkVt7IXAMVClEz617XphNyHErVoNduKz+i5AGsfQPdZIJf3R9Gfhs22GXZKYZS5KQBy5xfnk1Jq7QAJC36ePn5SPUC9dXEHLPwBLT+RMUnbsOVhrVKrC2ZzabT2rkWWnwnyWm/oDEYK8Mty/4myNYOu5TX+417aJlIT9MRnC+Uu3uh6DVL4Qfros93ncwVpzYfR0mzpt446m0ePQ7YdRiSMxU3no/zj4u1WQim+9GlK6U8dbv7artMdZvfFcV0DcGHYbMXmPXC3aBfYo1TFptSDGyOalgVBqwDvokfNDlNgf4NC1WLW1eF08jt491AlbMBnujHTcAT5opSjHw5AA2Z/qcCTKu/JJP1cyQ+jeyCPdmip8Lx1AG3iJBRTqnCsLIsQb004QXf1qA562Gh5DhdsezXoiCF1mi+cmtSiJDm9fD97D+BADdQglkiWDlS7wFhaqkyPlwDwoRJBSiMXAHkk9l+gI+A729xa1BTvcoZdKL5WFuU9zMfUt1Xj+aza5OSv5yJX0bLjOytz0r32EYh1aXVq+UJsCX2q0uQbBx35ez1m X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(136003)(396003)(346002)(376002)(451199015)(40470700004)(46966006)(36840700001)(86362001)(55446002)(83380400001)(478600001)(4326008)(8676002)(41300700001)(9686003)(26005)(5660300002)(316002)(6636002)(70586007)(110136005)(70206006)(54906003)(8936002)(336012)(2876002)(82310400005)(426003)(47076005)(40480700001)(186003)(81166007)(36756003)(40460700003)(2906002)(36860700001)(356005)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2022 09:30:26.4625 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c411d695-dc05-49fa-1ff2-08dab5a26250 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT111.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4957 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Support matching on EtherType, VLANs and ethernet source/destination addresses, with masking if supported by the hardware. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/mae.c | 36 +++++++++++++++++++ drivers/net/ethernet/sfc/mcdi.h | 6 ++++ drivers/net/ethernet/sfc/tc.c | 62 ++++++++++++++++++++++++++++++--- drivers/net/ethernet/sfc/tc.h | 4 +++ 4 files changed, 103 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/sfc/mae.c b/drivers/net/ethernet/sfc/mae.c index 4ceb8c8f5548..e119bc61ced7 100644 --- a/drivers/net/ethernet/sfc/mae.c +++ b/drivers/net/ethernet/sfc/mae.c @@ -284,9 +284,17 @@ int efx_mae_match_check_caps(struct efx_nic *efx, mask_type_name(ingress_port_mask_type)); return rc; } + CHECK(ETHER_TYPE, eth_proto); + CHECK(VLAN0_TCI, vlan_tci[0]); + CHECK(VLAN0_PROTO, vlan_proto[0]); + CHECK(VLAN1_TCI, vlan_tci[1]); + CHECK(VLAN1_PROTO, vlan_proto[1]); + CHECK(ETH_SADDR, eth_saddr); + CHECK(ETH_DADDR, eth_daddr); CHECK(RECIRC_ID, recirc_id); return 0; } +#undef CHECK static bool efx_mae_asl_id(u32 id) { @@ -459,6 +467,34 @@ static int efx_mae_populate_match_criteria(MCDI_DECLARE_STRUCT_PTR(match_crit), match->value.recirc_id); MCDI_STRUCT_SET_BYTE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_RECIRC_ID_MASK, match->mask.recirc_id); + MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_ETHER_TYPE_BE, + match->value.eth_proto); + MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_ETHER_TYPE_BE_MASK, + match->mask.eth_proto); + MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_VLAN0_TCI_BE, + match->value.vlan_tci[0]); + MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_VLAN0_TCI_BE_MASK, + match->mask.vlan_tci[0]); + MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_VLAN0_PROTO_BE, + match->value.vlan_proto[0]); + MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_VLAN0_PROTO_BE_MASK, + match->mask.vlan_proto[0]); + MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_VLAN1_TCI_BE, + match->value.vlan_tci[1]); + MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_VLAN1_TCI_BE_MASK, + match->mask.vlan_tci[1]); + MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_VLAN1_PROTO_BE, + match->value.vlan_proto[1]); + MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_VLAN1_PROTO_BE_MASK, + match->mask.vlan_proto[1]); + memcpy(MCDI_STRUCT_PTR(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_ETH_SADDR_BE), + match->value.eth_saddr, ETH_ALEN); + memcpy(MCDI_STRUCT_PTR(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_ETH_SADDR_BE_MASK), + match->mask.eth_saddr, ETH_ALEN); + memcpy(MCDI_STRUCT_PTR(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_ETH_DADDR_BE), + match->value.eth_daddr, ETH_ALEN); + memcpy(MCDI_STRUCT_PTR(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_ETH_DADDR_BE_MASK), + match->mask.eth_daddr, ETH_ALEN); return 0; } diff --git a/drivers/net/ethernet/sfc/mcdi.h b/drivers/net/ethernet/sfc/mcdi.h index 1f18e9dc62e8..883a4db695e2 100644 --- a/drivers/net/ethernet/sfc/mcdi.h +++ b/drivers/net/ethernet/sfc/mcdi.h @@ -224,6 +224,12 @@ void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev); #define MCDI_WORD(_buf, _field) \ ((u16)BUILD_BUG_ON_ZERO(MC_CMD_ ## _field ## _LEN != 2) + \ le16_to_cpu(*(__force const __le16 *)MCDI_PTR(_buf, _field))) +/* Write a 16-bit field defined in the protocol as being big-endian. */ +#define MCDI_STRUCT_SET_WORD_BE(_buf, _field, _value) do { \ + BUILD_BUG_ON(_field ## _LEN != 2); \ + BUILD_BUG_ON(_field ## _OFST & 1); \ + *(__force __be16 *)MCDI_STRUCT_PTR(_buf, _field) = (_value); \ + } while (0) #define MCDI_SET_DWORD(_buf, _field, _value) \ EFX_POPULATE_DWORD_1(*_MCDI_DWORD(_buf, _field), EFX_DWORD_0, _value) #define MCDI_STRUCT_SET_DWORD(_buf, _field, _value) \ diff --git a/drivers/net/ethernet/sfc/tc.c b/drivers/net/ethernet/sfc/tc.c index b21a961eabb1..b469a1263211 100644 --- a/drivers/net/ethernet/sfc/tc.c +++ b/drivers/net/ethernet/sfc/tc.c @@ -124,6 +124,20 @@ static void efx_tc_flow_free(void *ptr, void *arg) kfree(rule); } +/* Boilerplate for the simple 'copy a field' cases */ +#define _MAP_KEY_AND_MASK(_name, _type, _tcget, _tcfield, _field) \ +if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_##_name)) { \ + struct flow_match_##_type fm; \ + \ + flow_rule_match_##_tcget(rule, &fm); \ + match->value._field = fm.key->_tcfield; \ + match->mask._field = fm.mask->_tcfield; \ +} +#define MAP_KEY_AND_MASK(_name, _type, _tcfield, _field) \ + _MAP_KEY_AND_MASK(_name, _type, _type, _tcfield, _field) +#define MAP_ENC_KEY_AND_MASK(_name, _type, _tcget, _tcfield, _field) \ + _MAP_KEY_AND_MASK(ENC_##_name, _type, _tcget, _tcfield, _field) + static int efx_tc_flower_parse_match(struct efx_nic *efx, struct flow_rule *rule, struct efx_tc_match *match, @@ -144,26 +158,64 @@ static int efx_tc_flower_parse_match(struct efx_nic *efx, } if (dissector->used_keys & ~(BIT(FLOW_DISSECTOR_KEY_CONTROL) | - BIT(FLOW_DISSECTOR_KEY_BASIC))) { + BIT(FLOW_DISSECTOR_KEY_BASIC) | + BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS) | + BIT(FLOW_DISSECTOR_KEY_VLAN) | + BIT(FLOW_DISSECTOR_KEY_CVLAN))) { NL_SET_ERR_MSG_FMT_MOD(extack, "Unsupported flower keys %#x", dissector->used_keys); return -EOPNOTSUPP; } + MAP_KEY_AND_MASK(BASIC, basic, n_proto, eth_proto); if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) { struct flow_match_basic fm; flow_rule_match_basic(rule, &fm); - if (fm.mask->n_proto) { - NL_SET_ERR_MSG_MOD(extack, "Unsupported eth_proto match"); - return -EOPNOTSUPP; - } if (fm.mask->ip_proto) { NL_SET_ERR_MSG_MOD(extack, "Unsupported ip_proto match"); return -EOPNOTSUPP; } } + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_VLAN)) { + struct flow_match_vlan fm; + + flow_rule_match_vlan(rule, &fm); + if (fm.mask->vlan_id || fm.mask->vlan_priority || fm.mask->vlan_tpid) { + match->value.vlan_proto[0] = fm.key->vlan_tpid; + match->mask.vlan_proto[0] = fm.mask->vlan_tpid; + match->value.vlan_tci[0] = cpu_to_be16(fm.key->vlan_priority << 13 | + fm.key->vlan_id); + match->mask.vlan_tci[0] = cpu_to_be16(fm.mask->vlan_priority << 13 | + fm.mask->vlan_id); + } + } + + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CVLAN)) { + struct flow_match_vlan fm; + + flow_rule_match_cvlan(rule, &fm); + if (fm.mask->vlan_id || fm.mask->vlan_priority || fm.mask->vlan_tpid) { + match->value.vlan_proto[1] = fm.key->vlan_tpid; + match->mask.vlan_proto[1] = fm.mask->vlan_tpid; + match->value.vlan_tci[1] = cpu_to_be16(fm.key->vlan_priority << 13 | + fm.key->vlan_id); + match->mask.vlan_tci[1] = cpu_to_be16(fm.mask->vlan_priority << 13 | + fm.mask->vlan_id); + } + } + + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ETH_ADDRS)) { + struct flow_match_eth_addrs fm; + + flow_rule_match_eth_addrs(rule, &fm); + ether_addr_copy(match->value.eth_saddr, fm.key->src); + ether_addr_copy(match->value.eth_daddr, fm.key->dst); + ether_addr_copy(match->mask.eth_saddr, fm.mask->src); + ether_addr_copy(match->mask.eth_daddr, fm.mask->dst); + } + return 0; } diff --git a/drivers/net/ethernet/sfc/tc.h b/drivers/net/ethernet/sfc/tc.h index 4373c3243e3c..272efbabd6be 100644 --- a/drivers/net/ethernet/sfc/tc.h +++ b/drivers/net/ethernet/sfc/tc.h @@ -26,6 +26,10 @@ struct efx_tc_match_fields { /* L1 */ u32 ingress_port; u8 recirc_id; + /* L2 (inner when encap) */ + __be16 eth_proto; + __be16 vlan_tci[2], vlan_proto[2]; + u8 eth_saddr[ETH_ALEN], eth_daddr[ETH_ALEN]; }; struct efx_tc_match { From patchwork Mon Oct 24 09:29:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13016950 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26D50ECAAA1 for ; Mon, 24 Oct 2022 09:30:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230233AbiJXJap (ORCPT ); Mon, 24 Oct 2022 05:30:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230230AbiJXJac (ORCPT ); Mon, 24 Oct 2022 05:30:32 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2071.outbound.protection.outlook.com [40.107.93.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31F194623E for ; Mon, 24 Oct 2022 02:30:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fgb0bcuCquxqOH5h5dMz8tFqx6J0RqF23N01Tw5hXx9SdgWn/Zma8ISFmem1i1t5IBhzrZIgEuZBT06uiPJDEZ+z4JMuHT+MVm0lgn/atCGXSfzeqthAh/MRXEpvsVy8JkMY6ZJeZ/TMb2DeWGeMjQQP1N0+sZQIjQX+K28MulaIcRHsYXVnbmf3+SJOTB75HnKF09hCGCj7LK2V4QTqJN/YGp1HLSTaS7DT3Iv9qgS+cl4S942+LxqU2RnSKt7+i0Bl/Yn0po6/h3jXmkofRj3+sFUF5qgd8qMP0ZPo48yykDTPakawzIlZY6llHh/HgxsxZ7UqPvWnETr4ppcNLw== 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=HDhkyxF8awQ1Z3Qdjn5mgCWNApF6W4PJcevwFirjjhg=; b=iOG2DU+WHYFQfs7ILHUBX/EyJIMj1lkvzZdeR4oNwilqmW0od19JeZyf14A3oL5HYcV95ZM9DvWClseHX2aIvb2EvZJoN5lunZI+/1a5cWEnXBRbc4+IaCDScLdTKfoEJf6mGq4Sxhb1oPsXInoCVU3ODx2r5YxOcra/PJqRgLZQaJXGw2lj7VMO36l8o3fs2FjApL8XIX6fmKdlk6IetOw0hkht6owJWAWrm3e+BeF5lJpmSvYY13ENA+IAkKfRHyaWrNAstWeo+IKj+7wVNxIJLIWgYVU3uG3w+A7j6bSUYqBjSgFs8m7Sw+e0e6kIXT1dzXbnNUhC9JtsBMiILw== 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=HDhkyxF8awQ1Z3Qdjn5mgCWNApF6W4PJcevwFirjjhg=; b=GSAbTFKnnUqyBK234Rp9sA6e28YJVCHY4l6QX8WSq/Ul/7Pv2GJVbG9FoMQATQ1dbnzZVn7ZpwGmE35K6b+Iey8I+a7BK4c0QZPlF9MVgVj0x8o4ghw2+s6JpSJSpaaKc0DgsA743ar6Vbr5XV0WdikHWaIbeES3iYFqG0M0zIg= Received: from BN9PR03CA0507.namprd03.prod.outlook.com (2603:10b6:408:130::32) by DM4PR12MB6613.namprd12.prod.outlook.com (2603:10b6:8:b8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34; Mon, 24 Oct 2022 09:30:28 +0000 Received: from BN8NAM11FT107.eop-nam11.prod.protection.outlook.com (2603:10b6:408:130:cafe::30) by BN9PR03CA0507.outlook.office365.com (2603:10b6:408:130::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.27 via Frontend Transport; Mon, 24 Oct 2022 09:30:28 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT107.mail.protection.outlook.com (10.13.176.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5746.16 via Frontend Transport; Mon, 24 Oct 2022 09:30:28 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 24 Oct 2022 04:30:27 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 24 Oct 2022 04:30:27 -0500 Received: from xcbecree41x.xilinx.com (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.2375.31 via Frontend Transport; Mon, 24 Oct 2022 04:30:26 -0500 From: To: , CC: , , , , , Edward Cree Subject: [PATCH net-next 3/5] sfc: add Layer 3 matches to ef100 TC offload Date: Mon, 24 Oct 2022 10:29:23 +0100 Message-ID: <9dbf8f10ea50ec78791b3ddf740736904157e696.1666603600.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT107:EE_|DM4PR12MB6613:EE_ X-MS-Office365-Filtering-Correlation-Id: dcb90bd5-f538-4f88-9e39-08dab5a26343 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bPCKYEn08HUV9qmy8Pvi/i1GU/vRbNcFEfC95xlscPImEGcyrlNNrZQHox56LpqOPt//JacauWF1QbqAKV9I43iou6eXOUKnHzhH0DpaJlcctbC/gPG5onyWIhb4BRfLYnKt1WqupGVonA17rbZCUBEQTzaql/NhLw3ctUoP3B0Gwd/RImRQXoYi52nMWkyrhrDfjaAFpBNvwYOtXv229uZEkwHL2pssnRFeQrfuxZHzoO4MnJE8bODBd2snK5RLBapEeKjs7UtyPRz4vFcQ88Uubi7dVUv+kGKNOl2bVrt3M8cY65ccP2Tm2eZ80p391Ia8W82xpfsZRUksLj2ZVHaGvyx7dgKw7l9ZWvyF33KTAZ/ig2jv1wpMA6UK8tVOLAwr2eJJQEuik+e/zbGS0PWVNXVgv/vxtV7hR88on998qXNj9Q2TXN13toMyT+YtEOwim372iEWfe/xo09+SBzV9J0s0I2TYBHzo/ow8eGKXmD9ZGdbq8OLRcsrY9/2UtRSNH6wtstM/VCfQSATXr9Ybg0MOKY8s1QTk5xai3L9VbZU3u7W9ddOuMc6Tb7RIiiTQzs0SrG5WV1S0+PsarCXv9oXfDrI8WgoQ7BvtMnq4bMMXxn6SopMCBUCSkejmlNSa2CdRFVb+iPaDv4QP0C8oPX4wbSNgwWpNKWqLUzlM0e/CbQFltEsIcfEfAwRyUgh8VlJOoq/T3qgyhgtIHQEXul+KigIysnZIQrcyf6WnbLAPu7obYasD3qoUaJlV2si8iAo6bQrZMqgu6LHQ9pKyCUnWdNvKp/I0BdGwgxw= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(376002)(396003)(136003)(39860400002)(346002)(451199015)(40470700004)(36840700001)(46966006)(336012)(186003)(2876002)(40460700003)(6666004)(86362001)(55446002)(2906002)(82740400003)(36756003)(316002)(81166007)(356005)(26005)(83380400001)(41300700001)(9686003)(82310400005)(54906003)(426003)(47076005)(478600001)(36860700001)(8936002)(40480700001)(8676002)(4326008)(70586007)(110136005)(70206006)(5660300002)(6636002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2022 09:30:28.0582 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dcb90bd5-f538-4f88-9e39-08dab5a26343 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT107.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6613 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Support matching on IP protocol, Type of Service, Time To Live, source and destination addresses, with masking if supported by the hardware. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/mae.c | 39 +++++++++++++++++++++++ drivers/net/ethernet/sfc/mcdi.h | 6 ++++ drivers/net/ethernet/sfc/tc.c | 56 +++++++++++++++++++++++++++------ drivers/net/ethernet/sfc/tc.h | 8 +++++ 4 files changed, 100 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/sfc/mae.c b/drivers/net/ethernet/sfc/mae.c index e119bc61ced7..74de6a907a80 100644 --- a/drivers/net/ethernet/sfc/mae.c +++ b/drivers/net/ethernet/sfc/mae.c @@ -291,6 +291,15 @@ int efx_mae_match_check_caps(struct efx_nic *efx, CHECK(VLAN1_PROTO, vlan_proto[1]); CHECK(ETH_SADDR, eth_saddr); CHECK(ETH_DADDR, eth_daddr); + CHECK(IP_PROTO, ip_proto); + CHECK(IP_TOS, ip_tos); + CHECK(IP_TTL, ip_ttl); + CHECK(SRC_IP4, src_ip); + CHECK(DST_IP4, dst_ip); +#ifdef CONFIG_IPV6 + CHECK(SRC_IP6, src_ip6); + CHECK(DST_IP6, dst_ip6); +#endif CHECK(RECIRC_ID, recirc_id); return 0; } @@ -495,6 +504,36 @@ static int efx_mae_populate_match_criteria(MCDI_DECLARE_STRUCT_PTR(match_crit), match->value.eth_daddr, ETH_ALEN); memcpy(MCDI_STRUCT_PTR(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_ETH_DADDR_BE_MASK), match->mask.eth_daddr, ETH_ALEN); + MCDI_STRUCT_SET_BYTE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_IP_PROTO, + match->value.ip_proto); + MCDI_STRUCT_SET_BYTE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_IP_PROTO_MASK, + match->mask.ip_proto); + MCDI_STRUCT_SET_BYTE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_IP_TOS, + match->value.ip_tos); + MCDI_STRUCT_SET_BYTE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_IP_TOS_MASK, + match->mask.ip_tos); + MCDI_STRUCT_SET_BYTE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_IP_TTL, + match->value.ip_ttl); + MCDI_STRUCT_SET_BYTE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_IP_TTL_MASK, + match->mask.ip_ttl); + MCDI_STRUCT_SET_DWORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_SRC_IP4_BE, + match->value.src_ip); + MCDI_STRUCT_SET_DWORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_SRC_IP4_BE_MASK, + match->mask.src_ip); + MCDI_STRUCT_SET_DWORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_DST_IP4_BE, + match->value.dst_ip); + MCDI_STRUCT_SET_DWORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_DST_IP4_BE_MASK, + match->mask.dst_ip); +#ifdef CONFIG_IPV6 + memcpy(MCDI_STRUCT_PTR(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_SRC_IP6_BE), + &match->value.src_ip6, sizeof(struct in6_addr)); + memcpy(MCDI_STRUCT_PTR(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_SRC_IP6_BE_MASK), + &match->mask.src_ip6, sizeof(struct in6_addr)); + memcpy(MCDI_STRUCT_PTR(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_DST_IP6_BE), + &match->value.dst_ip6, sizeof(struct in6_addr)); + memcpy(MCDI_STRUCT_PTR(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_DST_IP6_BE_MASK), + &match->mask.dst_ip6, sizeof(struct in6_addr)); +#endif return 0; } diff --git a/drivers/net/ethernet/sfc/mcdi.h b/drivers/net/ethernet/sfc/mcdi.h index 883a4db695e2..fbeb58104936 100644 --- a/drivers/net/ethernet/sfc/mcdi.h +++ b/drivers/net/ethernet/sfc/mcdi.h @@ -236,6 +236,12 @@ void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev); EFX_POPULATE_DWORD_1(*_MCDI_STRUCT_DWORD(_buf, _field), EFX_DWORD_0, _value) #define MCDI_DWORD(_buf, _field) \ EFX_DWORD_FIELD(*_MCDI_DWORD(_buf, _field), EFX_DWORD_0) +/* Write a 32-bit field defined in the protocol as being big-endian. */ +#define MCDI_STRUCT_SET_DWORD_BE(_buf, _field, _value) do { \ + BUILD_BUG_ON(_field ## _LEN != 4); \ + BUILD_BUG_ON(_field ## _OFST & 3); \ + *(__force __be32 *)MCDI_STRUCT_PTR(_buf, _field) = (_value); \ + } while (0) #define MCDI_POPULATE_DWORD_1(_buf, _field, _name1, _value1) \ EFX_POPULATE_DWORD_1(*_MCDI_DWORD(_buf, _field), \ MC_CMD_ ## _name1, _value1) diff --git a/drivers/net/ethernet/sfc/tc.c b/drivers/net/ethernet/sfc/tc.c index b469a1263211..d992fafc844e 100644 --- a/drivers/net/ethernet/sfc/tc.c +++ b/drivers/net/ethernet/sfc/tc.c @@ -144,11 +144,29 @@ static int efx_tc_flower_parse_match(struct efx_nic *efx, struct netlink_ext_ack *extack) { struct flow_dissector *dissector = rule->match.dissector; + unsigned char ipv = 0; + /* Owing to internal TC infelicities, the IPV6_ADDRS key might be set + * even on IPv4 filters; so rather than relying on dissector->used_keys + * we check the addr_type in the CONTROL key. If we don't find it (or + * it's masked, which should never happen), we treat both IPV4_ADDRS + * and IPV6_ADDRS as absent. + */ if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CONTROL)) { struct flow_match_control fm; flow_rule_match_control(rule, &fm); + if (IS_ALL_ONES(fm.mask->addr_type)) + switch (fm.key->addr_type) { + case FLOW_DISSECTOR_KEY_IPV4_ADDRS: + ipv = 4; + break; + case FLOW_DISSECTOR_KEY_IPV6_ADDRS: + ipv = 6; + break; + default: + break; + } if (fm.mask->flags) { NL_SET_ERR_MSG_FMT_MOD(extack, "Unsupported match on control.flags %#x", @@ -161,22 +179,28 @@ static int efx_tc_flower_parse_match(struct efx_nic *efx, BIT(FLOW_DISSECTOR_KEY_BASIC) | BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS) | BIT(FLOW_DISSECTOR_KEY_VLAN) | - BIT(FLOW_DISSECTOR_KEY_CVLAN))) { + BIT(FLOW_DISSECTOR_KEY_CVLAN) | + BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS) | + BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS) | + BIT(FLOW_DISSECTOR_KEY_IP))) { NL_SET_ERR_MSG_FMT_MOD(extack, "Unsupported flower keys %#x", dissector->used_keys); return -EOPNOTSUPP; } MAP_KEY_AND_MASK(BASIC, basic, n_proto, eth_proto); - if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) { - struct flow_match_basic fm; - - flow_rule_match_basic(rule, &fm); - if (fm.mask->ip_proto) { - NL_SET_ERR_MSG_MOD(extack, "Unsupported ip_proto match"); - return -EOPNOTSUPP; + /* Make sure we're IP if any L3/L4 keys used. */ + if (!IS_ALL_ONES(match->mask.eth_proto) || + !(match->value.eth_proto == htons(ETH_P_IP) || + match->value.eth_proto == htons(ETH_P_IPV6))) + if (dissector->used_keys & + (BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS) | + BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS) | + BIT(FLOW_DISSECTOR_KEY_IP))) { + NL_SET_ERR_MSG_FMT_MOD(extack, "L3 flower keys %#x require protocol ipv[46]", + dissector->used_keys); + return -EINVAL; } - } if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_VLAN)) { struct flow_match_vlan fm; @@ -216,6 +240,20 @@ static int efx_tc_flower_parse_match(struct efx_nic *efx, ether_addr_copy(match->mask.eth_daddr, fm.mask->dst); } + MAP_KEY_AND_MASK(BASIC, basic, ip_proto, ip_proto); + MAP_KEY_AND_MASK(IP, ip, tos, ip_tos); + MAP_KEY_AND_MASK(IP, ip, ttl, ip_ttl); + if (ipv == 4) { + MAP_KEY_AND_MASK(IPV4_ADDRS, ipv4_addrs, src, src_ip); + MAP_KEY_AND_MASK(IPV4_ADDRS, ipv4_addrs, dst, dst_ip); + } +#ifdef CONFIG_IPV6 + else if (ipv == 6) { + MAP_KEY_AND_MASK(IPV6_ADDRS, ipv6_addrs, src, src_ip6); + MAP_KEY_AND_MASK(IPV6_ADDRS, ipv6_addrs, dst, dst_ip6); + } +#endif + return 0; } diff --git a/drivers/net/ethernet/sfc/tc.h b/drivers/net/ethernet/sfc/tc.h index 272efbabd6be..aebe9c251b2c 100644 --- a/drivers/net/ethernet/sfc/tc.h +++ b/drivers/net/ethernet/sfc/tc.h @@ -15,6 +15,8 @@ #include #include "net_driver.h" +#define IS_ALL_ONES(v) (!(typeof (v))~(v)) + struct efx_tc_action_set { u16 deliver:1; u32 dest_mport; @@ -30,6 +32,12 @@ struct efx_tc_match_fields { __be16 eth_proto; __be16 vlan_tci[2], vlan_proto[2]; u8 eth_saddr[ETH_ALEN], eth_daddr[ETH_ALEN]; + /* L3 (when IP) */ + u8 ip_proto, ip_tos, ip_ttl; + __be32 src_ip, dst_ip; +#ifdef CONFIG_IPV6 + struct in6_addr src_ip6, dst_ip6; +#endif }; struct efx_tc_match { From patchwork Mon Oct 24 09:29:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13016951 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 390B0FA373E for ; Mon, 24 Oct 2022 09:30:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230265AbiJXJas (ORCPT ); Mon, 24 Oct 2022 05:30:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230234AbiJXJac (ORCPT ); Mon, 24 Oct 2022 05:30:32 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2045.outbound.protection.outlook.com [40.107.92.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 732BC49B5E for ; Mon, 24 Oct 2022 02:30:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OBlY6meJl8vE4BsAz+12AQUUhGfzpsnXU4B1r0tYE/3bT94ljDUYIsxpbJm1FLtfJumn9nv96mks+1EFk98ahXzeeHIChO4eD2BPGVe6F3Sana3yL4oyHK2Znyp3ZtyI/xd/di+DJS2DHjw37vLZdVkYn9yKd4J2+q8ONPG3RgjH8Dmn8KcKZyZW1V5O7r1PLb5yx2iUeWv+Wf7IVrj+/a3ownnmWGzrnVvjrmarszAMQYCvLVkK/0BdXKSriGqFNmZbbIsvV3GRPef75m+MB30ZjkW8yfHGo7WyqXVysczsPTP7LeQghkS6nTstspmkXixequmeRaXEuH4HtOuq1g== 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=Fa86n8gaD59PsofhNsSbHk6vtq1e+crTjpk660LiLOM=; b=T8JfgJ58JJ8O+Okk2eALN+R6mrmgzOztUnWEyte9QPfb9VQNP/DlzO3JybbJmXhNeWFC16vL1Dfet4JENeuOgDgAOCbnHRCYrswVTupt93druKeX6zEzfHiOz3osZ6plb9BUsZxkSaDG81ry3E3jf3RbrYCAx+gy5excpGbeqXpvK99dHos4KEre1rJ/ImdvoeDH8k8bx3t4KjgirZuaUihWazbZg2P/0E8NSdVW7KWbjflGeDEPIqlXy4+tet5vsurLmIc0v8+FbOCNuZTxIF/pLviv/4/ngnDQsnQm9nlCh92BRyg9WhWuXA2KJaoVkiMcpKkGyL8ChdWjD+TmKg== 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=Fa86n8gaD59PsofhNsSbHk6vtq1e+crTjpk660LiLOM=; b=XH9CBpSYYUwTk2l/w83yt0fpU0IFCLGw9V7LZNZY9d1FMKr8XNQ8ls+pjd2wAJh5F4iK3kWiuj5nWe9EO6cNicB6N0RoX/1Bz/oxE6i/ZDtn3eFUgUliVSlhwy8VsFQ9K8oQpLO75KKWG+qpzZxHIt26cs9lvTZPbIWkE4kmpv8= Received: from BN0PR04CA0180.namprd04.prod.outlook.com (2603:10b6:408:eb::35) by MN0PR12MB6003.namprd12.prod.outlook.com (2603:10b6:208:37f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33; Mon, 24 Oct 2022 09:30:29 +0000 Received: from BN8NAM11FT068.eop-nam11.prod.protection.outlook.com (2603:10b6:408:eb:cafe::37) by BN0PR04CA0180.outlook.office365.com (2603:10b6:408:eb::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.28 via Frontend Transport; Mon, 24 Oct 2022 09:30:29 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT068.mail.protection.outlook.com (10.13.177.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5746.16 via Frontend Transport; Mon, 24 Oct 2022 09:30:29 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 24 Oct 2022 04:30:28 -0500 Received: from xcbecree41x.xilinx.com (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.2375.31 via Frontend Transport; Mon, 24 Oct 2022 04:30:27 -0500 From: To: , CC: , , , , , Edward Cree Subject: [PATCH net-next 4/5] sfc: add Layer 3 flag matches to ef100 TC offload Date: Mon, 24 Oct 2022 10:29:24 +0100 Message-ID: <468d6bc820d682f91ea9215953df90f87b01b881.1666603600.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT068:EE_|MN0PR12MB6003:EE_ X-MS-Office365-Filtering-Correlation-Id: 08b325db-d696-4c81-8cbd-08dab5a26407 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Rh8BYm0YTD77Vk7f8Vzd0A/xs/mDNSqkeZMl6+reOGbEDlVpeRMN5DVDl0ga+buqRtgB37H1Pj9iskAEVTwzmWM1itOTFhr5IZz2msnJomT/v5wj3PVzlEPU/T0d6EqBnkKN1b17dKbHQsBK49DGsp8NUvLXsxtOC8JwxYSQB7A8OWoedP//HCzvZJYUHA3h9jnworpWcqo8soTv/MtJF2PGe0C4n0D2rMz0gnEqRrYG4FFgmLDzvqtWJna4fk8mNjl/RCUOgiqkCzJAdTaYQC7YiERuat1MBTeG+u7wEhe2a8kg/trYqojrnJTKLMQrkaqwZfZuNJ/RhiHBPjxwGn1qAaS0tkY8m+37j+X9LfGdDwr8u7ZyfdDp/jy19rIHIEzBaGxHrCRaIi7gHMRvwqnqmIqjBe/dVbYrdHvKhmwn/QV3uqhDhtJc8OY/hUZ++MOH1w91Pz4CzbXsn/AD0uW6E/3P5tqeOGUnXz2RkkegM5V3RrqF/UB3s2oDBbngL+win64xceFr7nBzElUvvlUTQDEcKQid//ALSLzHW6XZD2h3wQUqWoH13TWY49dYBw5CVO5Dkf6TGQx1AHQDn6TEWv7VNOqhVxRhEx4MrutZyuh1+kHrMq8VOWT0rlXJfipbLK1t7wraT2UOqpBblSzdg4tqdZUbjNgLExXEbxA/y8YeXYbgMMotT1ByklDnXIrSfT1opz1MnwSeXu5z/gWqXIrN3MbDMt4K4gvZ53t6N6lpHYRNU7jas0qFEtKfQ85bN5/AZhbWA5G+yUmyUj91/DfLR1mr+EZrshKFuNavB7R2eZP27taBRJDNhdGL X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(376002)(346002)(396003)(136003)(39860400002)(451199015)(36840700001)(40470700004)(46966006)(70206006)(70586007)(9686003)(4326008)(6666004)(47076005)(86362001)(82740400003)(36756003)(186003)(5660300002)(2876002)(2906002)(8936002)(41300700001)(82310400005)(8676002)(356005)(40480700001)(26005)(336012)(426003)(36860700001)(40460700003)(81166007)(55446002)(6636002)(110136005)(54906003)(83380400001)(316002)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2022 09:30:29.3423 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 08b325db-d696-4c81-8cbd-08dab5a26407 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT068.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6003 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Support matching on ip_frag and ip_firstfrag. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/mae.c | 26 ++++++++++++++++++++++++++ drivers/net/ethernet/sfc/tc.c | 10 +++++++++- drivers/net/ethernet/sfc/tc.h | 1 + 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/sfc/mae.c b/drivers/net/ethernet/sfc/mae.c index 74de6a907a80..76b75b3975d5 100644 --- a/drivers/net/ethernet/sfc/mae.c +++ b/drivers/net/ethernet/sfc/mae.c @@ -264,6 +264,19 @@ static int efx_mae_match_check_cap_typ(u8 support, enum mask_type typ) return rc; \ } \ } while (0) +/* Booleans need special handling */ +#define CHECK_BIT(_mcdi, _field) do { \ + enum mask_type typ = mask->_field ? MASK_ONES : MASK_ZEROES; \ + \ + rc = efx_mae_match_check_cap_typ(supported_fields[MAE_FIELD_ ## _mcdi],\ + typ); \ + if (rc) { \ + NL_SET_ERR_MSG_FMT_MOD(extack, \ + "No support for %s mask in field %s", \ + mask_type_name(typ), #_field); \ + return rc; \ + } \ +} while (0) int efx_mae_match_check_caps(struct efx_nic *efx, const struct efx_tc_match_fields *mask, @@ -300,9 +313,12 @@ int efx_mae_match_check_caps(struct efx_nic *efx, CHECK(SRC_IP6, src_ip6); CHECK(DST_IP6, dst_ip6); #endif + CHECK_BIT(IS_IP_FRAG, ip_frag); + CHECK_BIT(IP_FIRST_FRAG, ip_firstfrag); CHECK(RECIRC_ID, recirc_id); return 0; } +#undef CHECK_BIT #undef CHECK static bool efx_mae_asl_id(u32 id) @@ -472,6 +488,16 @@ static int efx_mae_populate_match_criteria(MCDI_DECLARE_STRUCT_PTR(match_crit), } MCDI_STRUCT_SET_DWORD(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_INGRESS_MPORT_SELECTOR_MASK, match->mask.ingress_port); + EFX_POPULATE_DWORD_2(*_MCDI_STRUCT_DWORD(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_FLAGS), + MAE_FIELD_MASK_VALUE_PAIRS_V2_IS_IP_FRAG, + match->value.ip_frag, + MAE_FIELD_MASK_VALUE_PAIRS_V2_IP_FIRST_FRAG, + match->value.ip_firstfrag); + EFX_POPULATE_DWORD_2(*_MCDI_STRUCT_DWORD(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_FLAGS_MASK), + MAE_FIELD_MASK_VALUE_PAIRS_V2_IS_IP_FRAG, + match->mask.ip_frag, + MAE_FIELD_MASK_VALUE_PAIRS_V2_IP_FIRST_FRAG, + match->mask.ip_firstfrag); MCDI_STRUCT_SET_BYTE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_RECIRC_ID, match->value.recirc_id); MCDI_STRUCT_SET_BYTE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_RECIRC_ID_MASK, diff --git a/drivers/net/ethernet/sfc/tc.c b/drivers/net/ethernet/sfc/tc.c index d992fafc844e..1a9cc2ad1335 100644 --- a/drivers/net/ethernet/sfc/tc.c +++ b/drivers/net/ethernet/sfc/tc.c @@ -168,7 +168,15 @@ static int efx_tc_flower_parse_match(struct efx_nic *efx, break; } - if (fm.mask->flags) { + if (fm.mask->flags & FLOW_DIS_IS_FRAGMENT) { + match->value.ip_frag = fm.key->flags & FLOW_DIS_IS_FRAGMENT; + match->mask.ip_frag = true; + } + if (fm.mask->flags & FLOW_DIS_FIRST_FRAG) { + match->value.ip_firstfrag = fm.key->flags & FLOW_DIS_FIRST_FRAG; + match->mask.ip_firstfrag = true; + } + if (fm.mask->flags & ~(FLOW_DIS_IS_FRAGMENT | FLOW_DIS_FIRST_FRAG)) { NL_SET_ERR_MSG_FMT_MOD(extack, "Unsupported match on control.flags %#x", fm.mask->flags); return -EOPNOTSUPP; diff --git a/drivers/net/ethernet/sfc/tc.h b/drivers/net/ethernet/sfc/tc.h index aebe9c251b2c..d2b61926657b 100644 --- a/drivers/net/ethernet/sfc/tc.h +++ b/drivers/net/ethernet/sfc/tc.h @@ -38,6 +38,7 @@ struct efx_tc_match_fields { #ifdef CONFIG_IPV6 struct in6_addr src_ip6, dst_ip6; #endif + bool ip_frag, ip_firstfrag; }; struct efx_tc_match { From patchwork Mon Oct 24 09:29:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13016952 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 341C1ECAAA1 for ; Mon, 24 Oct 2022 09:31:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230337AbiJXJbE (ORCPT ); Mon, 24 Oct 2022 05:31:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230229AbiJXJap (ORCPT ); Mon, 24 Oct 2022 05:30:45 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2053.outbound.protection.outlook.com [40.107.237.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53D6D52823 for ; Mon, 24 Oct 2022 02:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OSeWN7JwKl5X23WoDU4ucVOMmri3XKpOjzMJ9a1Q+t+Z0Ndde0TS/RTqqgWrHlGLBhRnF5CzIx3zgqmvjTL9jo18e7Kvo05W/1Owq8wEFL8ZSazNNAKaqUr63oKvQY/WkzQ9s0KGm6zRXDOILhCIh4RMk7yyC15zapZjcDmYTv6WhEJSfRg3ioQuDVg7s079BhWVGY2lGBb1niDM8mUm6WfuOHH+kc3/3rA7Jp1b7qy4fNJOPQlQhxI2kbiMMR6sNUTpO8pHLcC1jw7N+Qg4rn4s1dfYB14uoig8wPNRiGOyRb+ynv3g9sv/PL+D1J6V6nrgX231kXTry8aN/thh0w== 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=YE4GQ70AcuyPgMvCr/DL4EcuWyY0iXA1gt4/dgl/yPw=; b=jyeOVaDzhuFbgEbVsYe9rDKPHrFz9yEMuCGkuJ18FPI08bAF9kLKr2SOxLm74cOdkt4BqgfTsPkucs2DFPrqL4APCpq2GJW8Q3yppXGxJ5PkrEaV2rpY3sop8UyHLowQ2l+ZB5qf8ZqTMBwNAgyHDPFqTIawWhZgHze2r68HLNlkWr2mrVJnRctTt78pKR4Jv7An6uwhIMMNPGh3U8eFSldzQVFe44z4N3nMyEjKIaWd8j2honY6aIsIJYKQEyEstouHzMxBUQ+4QLEeG7QDmbw4D81I77m+rsReGSX22RGrYSzRUiaGv3PHfdgorvEXjDEO7PRKMbM7aD4d5RGa9A== 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=YE4GQ70AcuyPgMvCr/DL4EcuWyY0iXA1gt4/dgl/yPw=; b=d5Wl+FodwOJi6SiIQPRi8SDTpzezZdA01Ss4lB8ZHTKAJJ2reV96AV/jHfEHHswcGw4dx63wPD6SmZz+0K8F0nYVLqvbyKdv1tD/wdkSZ7KOnPGXxbTJ2ztjRkxfpTuWegN6Rcj39lbT4WIX1wZbDE27xJhQm9HH2yMy9SvqRDA= Received: from MW4PR03CA0046.namprd03.prod.outlook.com (2603:10b6:303:8e::21) by DM4PR12MB5293.namprd12.prod.outlook.com (2603:10b6:5:390::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34; Mon, 24 Oct 2022 09:30:34 +0000 Received: from CO1NAM11FT074.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8e:cafe::cb) by MW4PR03CA0046.outlook.office365.com (2603:10b6:303:8e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.27 via Frontend Transport; Mon, 24 Oct 2022 09:30:34 +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 CO1NAM11FT074.mail.protection.outlook.com (10.13.174.254) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5746.16 via Frontend Transport; Mon, 24 Oct 2022 09:30:34 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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.2375.31; Mon, 24 Oct 2022 04:30:30 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 24 Oct 2022 04:30:30 -0500 Received: from xcbecree41x.xilinx.com (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.2375.31 via Frontend Transport; Mon, 24 Oct 2022 04:30:29 -0500 From: To: , CC: , , , , , Edward Cree Subject: [PATCH net-next 5/5] sfc: add Layer 4 matches to ef100 TC offload Date: Mon, 24 Oct 2022 10:29:25 +0100 Message-ID: <9d30e1b05dd84ab47d7627b1a0236ea79d70b5fa.1666603600.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT074:EE_|DM4PR12MB5293:EE_ X-MS-Office365-Filtering-Correlation-Id: d3c46e16-bede-424f-4e9f-08dab5a266e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BnBvVWBBFEkRf/2o7r26+O7Btg2kzRmyEfNOuhdPTIQpsRFxUvZ4AsL1qt0dA+qAF/n52BpNiL3vFLkjF9tMxctwfSDjewNJgwK+H6AEKZ5RsjzJd4kFULEm6NXr6hZSMc/k6ZASMScm//X6r17Mnob6JXDBsi4cCrzRXIuIS4EOvR9hRYSRzMAl/5IX8WLcKy8lRV9x5hvlKtQsDohJvezmNG0IZxYHhI4bffrZXkzkmtP/o27D3PDPvqz+2LyhCv+M+6XI++71jSDCorpiwz8BPZyFhynwjPR4SVbN5vrQ2NMu0n5OdFhoyG7Hds56VgVjfFE/aEJtvCoKrauDwfEXOPoUz9JYqnMmM3mY/DYiigJIxjcU3YgeXf+5p/RCGfFI9a4sudY944Oo3J5KjPGTTHkT6bbzuUXT3oFkh8OUdiORhANwYnRG4B31eReaBMnCy1fdNS83g+C7Ln7SA92Ngl3xYpn/kd5j4V85gkxov1LFg9X1TIh66Hmsw9Ce93sL9BNbRSC7QSOhZ+LRCf5oDDqY4wSguG3U41FSC/74tJKiD1IWXQR9ys2mwTxjcf+AGOwioxkAkP2u137AgttkD8hOUDODapw83KuUh98fIVUaZxbtvOAVDhP+ZZBnkg0kGqOgEF5kKCvQGQ+dpEmRCd5ZbAVBn++NPyrBIEX8WjjVt8taB4ACdO+Xew4icQA1t8unvlLTwIq1nxOSiorjllZaVaquQiU0JZ2M5LY9i7M5EV2+gmUW9AjxwQtKqc1SAL7w7eijKHpc6epVVtDEs8RXXMH1qbalt+XJS5yHsirRXiALtM42+0bobSGT 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:(13230022)(4636009)(376002)(346002)(136003)(396003)(39860400002)(451199015)(46966006)(36840700001)(40470700004)(82310400005)(36756003)(55446002)(426003)(41300700001)(82740400003)(356005)(86362001)(47076005)(36860700001)(336012)(5660300002)(40460700003)(83380400001)(81166007)(316002)(2876002)(40480700001)(26005)(478600001)(70586007)(6666004)(2906002)(70206006)(8676002)(4326008)(6636002)(8936002)(9686003)(110136005)(186003)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2022 09:30:34.0089 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d3c46e16-bede-424f-4e9f-08dab5a266e0 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: CO1NAM11FT074.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5293 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Support matching on UDP/TCP source and destination ports and TCP flags, with masking if supported by the hardware. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/mae.c | 15 +++++++++++++++ drivers/net/ethernet/sfc/tc.c | 21 +++++++++++++++++++-- drivers/net/ethernet/sfc/tc.h | 3 +++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/sfc/mae.c b/drivers/net/ethernet/sfc/mae.c index 76b75b3975d5..19b73cef5b30 100644 --- a/drivers/net/ethernet/sfc/mae.c +++ b/drivers/net/ethernet/sfc/mae.c @@ -313,6 +313,9 @@ int efx_mae_match_check_caps(struct efx_nic *efx, CHECK(SRC_IP6, src_ip6); CHECK(DST_IP6, dst_ip6); #endif + CHECK(L4_SPORT, l4_sport); + CHECK(L4_DPORT, l4_dport); + CHECK(TCP_FLAGS, tcp_flags); CHECK_BIT(IS_IP_FRAG, ip_frag); CHECK_BIT(IP_FIRST_FRAG, ip_firstfrag); CHECK(RECIRC_ID, recirc_id); @@ -560,6 +563,18 @@ static int efx_mae_populate_match_criteria(MCDI_DECLARE_STRUCT_PTR(match_crit), memcpy(MCDI_STRUCT_PTR(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_DST_IP6_BE_MASK), &match->mask.dst_ip6, sizeof(struct in6_addr)); #endif + MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_L4_SPORT_BE, + match->value.l4_sport); + MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_L4_SPORT_BE_MASK, + match->mask.l4_sport); + MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_L4_DPORT_BE, + match->value.l4_dport); + MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_L4_DPORT_BE_MASK, + match->mask.l4_dport); + MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_TCP_FLAGS_BE, + match->value.tcp_flags); + MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_TCP_FLAGS_BE_MASK, + match->mask.tcp_flags); return 0; } diff --git a/drivers/net/ethernet/sfc/tc.c b/drivers/net/ethernet/sfc/tc.c index 1a9cc2ad1335..17e1a3447554 100644 --- a/drivers/net/ethernet/sfc/tc.c +++ b/drivers/net/ethernet/sfc/tc.c @@ -190,6 +190,8 @@ static int efx_tc_flower_parse_match(struct efx_nic *efx, BIT(FLOW_DISSECTOR_KEY_CVLAN) | BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS) | BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS) | + BIT(FLOW_DISSECTOR_KEY_PORTS) | + BIT(FLOW_DISSECTOR_KEY_TCP) | BIT(FLOW_DISSECTOR_KEY_IP))) { NL_SET_ERR_MSG_FMT_MOD(extack, "Unsupported flower keys %#x", dissector->used_keys); @@ -204,8 +206,10 @@ static int efx_tc_flower_parse_match(struct efx_nic *efx, if (dissector->used_keys & (BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS) | BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS) | - BIT(FLOW_DISSECTOR_KEY_IP))) { - NL_SET_ERR_MSG_FMT_MOD(extack, "L3 flower keys %#x require protocol ipv[46]", + BIT(FLOW_DISSECTOR_KEY_PORTS) | + BIT(FLOW_DISSECTOR_KEY_IP) | + BIT(FLOW_DISSECTOR_KEY_TCP))) { + NL_SET_ERR_MSG_FMT_MOD(extack, "L3/L4 flower keys %#x require protocol ipv[46]", dissector->used_keys); return -EINVAL; } @@ -249,6 +253,16 @@ static int efx_tc_flower_parse_match(struct efx_nic *efx, } MAP_KEY_AND_MASK(BASIC, basic, ip_proto, ip_proto); + /* Make sure we're TCP/UDP if any L4 keys used. */ + if ((match->value.ip_proto != IPPROTO_UDP && + match->value.ip_proto != IPPROTO_TCP) || !IS_ALL_ONES(match->mask.ip_proto)) + if (dissector->used_keys & + (BIT(FLOW_DISSECTOR_KEY_PORTS) | + BIT(FLOW_DISSECTOR_KEY_TCP))) { + NL_SET_ERR_MSG_FMT_MOD(extack, "L4 flower keys %#x require ipproto udp or tcp", + dissector->used_keys); + return -EINVAL; + } MAP_KEY_AND_MASK(IP, ip, tos, ip_tos); MAP_KEY_AND_MASK(IP, ip, ttl, ip_ttl); if (ipv == 4) { @@ -261,6 +275,9 @@ static int efx_tc_flower_parse_match(struct efx_nic *efx, MAP_KEY_AND_MASK(IPV6_ADDRS, ipv6_addrs, dst, dst_ip6); } #endif + MAP_KEY_AND_MASK(PORTS, ports, src, l4_sport); + MAP_KEY_AND_MASK(PORTS, ports, dst, l4_dport); + MAP_KEY_AND_MASK(TCP, tcp, flags, tcp_flags); return 0; } diff --git a/drivers/net/ethernet/sfc/tc.h b/drivers/net/ethernet/sfc/tc.h index d2b61926657b..4240c375a8e6 100644 --- a/drivers/net/ethernet/sfc/tc.h +++ b/drivers/net/ethernet/sfc/tc.h @@ -39,6 +39,9 @@ struct efx_tc_match_fields { struct in6_addr src_ip6, dst_ip6; #endif bool ip_frag, ip_firstfrag; + /* L4 */ + __be16 l4_sport, l4_dport; /* Ports (UDP, TCP) */ + __be16 tcp_flags; }; struct efx_tc_match {