From patchwork Thu Nov 3 15:27:27 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: 13030408 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 0F629C43217 for ; Thu, 3 Nov 2022 15:28:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231726AbiKCP2c (ORCPT ); Thu, 3 Nov 2022 11:28:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230096AbiKCP2F (ORCPT ); Thu, 3 Nov 2022 11:28:05 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2075.outbound.protection.outlook.com [40.107.243.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E40971B1FB for ; Thu, 3 Nov 2022 08:28:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MNFy+lDy/z982RCnuphryJJHSrrV+OELqF7nu9yLthxyY0bb6xvNjVLXAtpmHYOzqDKZ0JUJRyHE2Cjus017cyjdnggIC6AbEYnFJmjFYcrJ6ltufTs9+XP1dpRH5Qqrk6c36fpPlHEoq39fA80S8IEjenlo0FFNT8c5DApeftNqXKYGwOsHceKFOm77ruDwmokFAw8gRIl8Fsyd8JyZrlYxOpuoVi6hJLSuMMRyvgB9LOvs7njiv/fxrsp8r+VbxEpGmxXfnSFQOfA4IrLkoV4eDi1/t60en+GIvEd4BnpiZuyBADSYrX9yeegCtaIffZatdUDdzrZfNZZZS3OEVw== 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=YASliACehkvQH7oZxZz3NMQ79jS8k5TpmXs3KHSooJg=; b=X9FDPNU3vv+0W1OB80kkPluepshnXUBVTmSQZ5aVClRs+hepO5c3dVzzEee0L7WgnPJWqfF99ou9MBPFUgT8Ebr7vy8MW0Ty/DtFCUmhyti3ug4/z7q3pNMdTAdoyFv+/ux6jcJsjqF4VjEXO1zrSprbyOTSBrL5qt/RzcTMQNRJoupluCCfYmoKnCQi4PlWITFn9/iBPsZEOyOObdx3EkEG6qTSTa1e+tNPOuYvRM1otaPVIjE6Gco0fUKg3buHM7I+dQqX41iVL5jHSljsdw8lhhGTO2wNGIk+OegLo2/ITtlkJZHJFTjKOMvTYZHuWRE5gc4OT/jbIo2V6PC/iw== 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=YASliACehkvQH7oZxZz3NMQ79jS8k5TpmXs3KHSooJg=; b=mxi5aDNw5vqQ8QyGe14DStn2r8ChChyxIz5uA1lhTtt00EmS3sGsdTSoqNtsbZdGGYRRmJNmZzl/x/3okJCs3+VoXnsBvhSddtrKWv6YErw2v9Bb/Anwd8VdeT5xkj8QYLzcvXc9UAe/u3FU3NEVqsKbWLfxkiRHLRVbKxxkO4A= Received: from DM6PR13CA0062.namprd13.prod.outlook.com (2603:10b6:5:134::39) by SA0PR12MB4413.namprd12.prod.outlook.com (2603:10b6:806:9e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.18; Thu, 3 Nov 2022 15:28:01 +0000 Received: from DM6NAM11FT068.eop-nam11.prod.protection.outlook.com (2603:10b6:5:134:cafe::cc) by DM6PR13CA0062.outlook.office365.com (2603:10b6:5:134::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.22 via Frontend Transport; Thu, 3 Nov 2022 15:28:01 +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 DM6NAM11FT068.mail.protection.outlook.com (10.13.173.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5791.20 via Frontend Transport; Thu, 3 Nov 2022 15:28:01 +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; Thu, 3 Nov 2022 10:28:01 -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; Thu, 3 Nov 2022 10:28:00 -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; Thu, 3 Nov 2022 10:27:59 -0500 From: To: , CC: , , , , , Edward Cree Subject: [PATCH v2 net-next 1/5] sfc: check recirc_id match caps before MAE offload Date: Thu, 3 Nov 2022 15:27:27 +0000 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: DM6NAM11FT068:EE_|SA0PR12MB4413:EE_ X-MS-Office365-Filtering-Correlation-Id: 88b9deaa-c27c-44eb-69ee-08dabdaffea9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SjJQ4izKmdlhv9SQsndae5mPcoTg0G9RMNHveYSiIvpf47fvrOFjgXWEs8+LqDkw45uS136tB66beSY5O1dkv+/0g7XHesYU0ao9YDBPT9y9S4znIzF/kbZGL6aGdlobe17VoE2ihqLoeeCOIHbpLlvjO6PT/CWv/jwQ7Za0mQDE2aATmdacoamvWnm/P8Dv93eT/UAdMURYs6Ee3hmd7bIplLxvaKUVUL/doFZEtSmZEvs8j3nH/Nfo/dy/Hx6DtH+StPU3zbYbZ4blNJUTa2MjO295d9xn1cGNQgMMnhBNfixN30DKfRog7ULBuQT/7lnr5sPfXedkZxr923UuYBzBi+a0EUKhMWHcCukpH6XhkSDyjV95HLJtmyFvXSrcX0gx01y2CVTe4LRFoWPuAyp1Uv6mvYqp4Qa7uXx/QIegDeQvTqrr9vpc+wxDBfDrN5P79JJ37nEmSo6wt2YWR8nmTzQh+KqbK9ZZdOBs1kgu9VKDHwIORH1sPSlG38Eb81jPTLXc2rk4S8YgReuEj04eMnwxLlW7MaU7RWkVcJLKk/f18jQw7AJ/GKAyfhfhWTtSyeeaZ7YKc/0UVmL1hXjXsIuWZoBXGRtnjSYqqpdtXCeXMm865jFkyfu+Ba8C3xhLAKCZgVMuD8qle5bXx/Cf7oZ4Q3EWeaMLCAWdjbDXm5OKB5aaFiyuSOOKfN74n2JZ45XcoHhB2b/FA5eLywwfS8jyC89evpcgdnSHja3jh3+N49kND3wQ3gPJ9EP5awwfi7mTJsPFTK5S9pcYP1bnXHgdpBy9wb1EIi3ksy4= 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)(136003)(396003)(346002)(376002)(39860400002)(451199015)(36840700001)(46966006)(40470700004)(426003)(47076005)(83380400001)(41300700001)(336012)(2906002)(2876002)(6666004)(4326008)(55446002)(81166007)(36756003)(40460700003)(356005)(86362001)(40480700001)(82740400003)(36860700001)(110136005)(82310400005)(9686003)(186003)(26005)(6636002)(70586007)(70206006)(316002)(5660300002)(8676002)(8936002)(54906003)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2022 15:28:01.5163 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 88b9deaa-c27c-44eb-69ee-08dabdaffea9 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: DM6NAM11FT068.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4413 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. These checks allow us to fail early, avoiding the PCIe round-trip to firmware for an MC_CMD_MAE_ACTION_RULE_INSERT that will only fail, and more importantly providing a more informative error message that identifies which match field is unsupported. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/mae.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/net/ethernet/sfc/mae.c b/drivers/net/ethernet/sfc/mae.c index 6f472ea0638a..cd014957a236 100644 --- a/drivers/net/ethernet/sfc/mae.c +++ b/drivers/net/ethernet/sfc/mae.c @@ -250,6 +250,20 @@ static int efx_mae_match_check_cap_typ(u8 support, enum mask_type typ) } } +/* Validate field mask against hardware capabilities. Captures caller's 'rc' */ +#define CHECK(_mcdi, _field) ({ \ + 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); \ + rc; \ +}) + int efx_mae_match_check_caps(struct efx_nic *efx, const struct efx_tc_match_fields *mask, struct netlink_ext_ack *extack) @@ -269,8 +283,11 @@ int efx_mae_match_check_caps(struct efx_nic *efx, mask_type_name(ingress_port_mask_type)); return rc; } + if (CHECK(RECIRC_ID, recirc_id)) + return rc; return 0; } +#undef CHECK static bool efx_mae_asl_id(u32 id) { From patchwork Thu Nov 3 15:27:28 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: 13030409 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 EAAE4C433FE for ; Thu, 3 Nov 2022 15:28:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232196AbiKCP2j (ORCPT ); Thu, 3 Nov 2022 11:28:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232223AbiKCP2G (ORCPT ); Thu, 3 Nov 2022 11:28:06 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2085.outbound.protection.outlook.com [40.107.95.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9105C1B9D4 for ; Thu, 3 Nov 2022 08:28:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GqCdHvDp669YsdY5IFrWrsDgWsBDGYeFrepsTgD7FxjXRg+J9V5sFuOZD0hSa6gi6nTgWNLNuNSV2HlqqhVQFetEpdtz24KbrKQT5TBwqbwc2r+gjROksiFzWJ9sXcrT5cvnN9zWadHYXMH8eTm8ThzV3QhaGFOjXN/YUjFE+PbrB1TbrIXI++DDkVNlgueks6+FMZsHyDM+DsPMRrIcbQ4SsR1bvzJXhuCJ+NX+dlD3sbUQbQer0IQHAIRq6RD0T6DnWzJGQDHLXdpNJU60jJgmVyvsGJT8PTn73S2W96sdnD+QGho4fbULnbRA8HH9oRmNYkE/u2kNjAu6OLBPWw== 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=CqY2f3SFbaMJhbZrCV85Kf/pLnLp4y+Nx+B4oFzVjpg=; b=jdaRvM16dYc/SsjhihX+82HykVHEToM1AL+/rKyr6iG+acGNUs1lpYNDYmS/+4/fgJI3o0MAUySyp4WH/X1y+4u66y4l8pJmAmdPaCpd5agvGExSwMGOizAyQYxuPHzzcP+NQzsZXhiXSilyQhUSqZ22hbsoKtV/fQ84VH0NBmPnNbBHfDZo0y7kuFTEDljFXbAWkGRTxyLIbl4xYy/Z9mrh2wSUeLMQZ8xPlSM8IrFwbmLfdCu2ACvPxFoRf7zW7GOua81YxvJfwB6Uy06JwXSvQBvYA0dvT+DCqVG+ms7DLZm/bCBMDE+mchYQJXti3V3j0DYPdpaxZN5gPgiKlg== 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=CqY2f3SFbaMJhbZrCV85Kf/pLnLp4y+Nx+B4oFzVjpg=; b=LHnHvgyeM9JUaVTGVq+YLPlfYqMDulT76srxs7Xd5ZLFKsWBGF9g08JikgvUIMiULTOn78jU1iGdavVCSjjV/Z+Zm0Xa26oq7h67PrgdAVDwgIhilep4jCoMASTcK9aRB5Je9Z725Zy/VMxp8nD3r1vegcUzVGpxJTveDveT/pg= Received: from DM6PR07CA0068.namprd07.prod.outlook.com (2603:10b6:5:74::45) by MN0PR12MB5906.namprd12.prod.outlook.com (2603:10b6:208:37a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.16; Thu, 3 Nov 2022 15:28:03 +0000 Received: from DM6NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:5:74:cafe::ee) by DM6PR07CA0068.outlook.office365.com (2603:10b6:5:74::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.22 via Frontend Transport; Thu, 3 Nov 2022 15:28:02 +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 DM6NAM11FT008.mail.protection.outlook.com (10.13.172.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5791.20 via Frontend Transport; Thu, 3 Nov 2022 15:28:02 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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; Thu, 3 Nov 2022 10:28:02 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 3 Nov 2022 08:28:02 -0700 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; Thu, 3 Nov 2022 10:28:00 -0500 From: To: , CC: , , , , , Edward Cree Subject: [PATCH v2 net-next 2/5] sfc: add Layer 2 matches to ef100 TC offload Date: Thu, 3 Nov 2022 15:27:28 +0000 Message-ID: <251c83113eb4caa9f8b628ce5b14983f6ebc23ea.1667412458.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: DM6NAM11FT008:EE_|MN0PR12MB5906:EE_ X-MS-Office365-Filtering-Correlation-Id: 5707cb2e-4b71-4feb-8b54-08dabdafff74 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p0MRscwvvOF9+c4j6kbXArMrkfq8t1vwzoUaTMVPVM6haYreVMxeoPKmAvkAo5XxVM/1wPwYCEGVFQAOTxcw9aMF1QSsJkXwcxO4yyN0ainFzXyfT/GXgwJ37tYIg0gcqVYonomRuzGJnKtAiYWFy7vppuf7IijVNQt2v9P7W2bBRBcQYzQ6CLL7Mq3ithhylyuJHQjJf9p1DW/Bckg8R4x/VTYHJcrt4JTOa7gAFMRB/30wfU3QXLJ3cN9X6l31xOMO2l8+MaAm/2BzmzaKnrVMSBN1mxMajLkVsxWFLWyfKrerTp3N95w7j0ArnV8d9p6nDxsKDho52bXKWmwJ0/mty6NP8dzbtmEjsW1eRiF4Am6SwOtQ3gIxdAPTwGa1Rv/0oLOzKRJKwz1qA/wNRdEW3NM6xbSLgMvFGL388yqoMtxxlTiGTl3eD/ZAegF9bGDzm+PfwsoJRW99XcvZTUJjJZqgOZh8TNccHEF8wQ1fdYomjbzE93jXLRm3hssrKI5zGWTbFKQaB6f/i7AUOedTM+K9HJmM6aGxiSrDsVvHTpKxxNn9I8VwiBlOJAAPilQ3j6vdCqezLgiTuNwuhO8CLJaxHfFvFQNa+9WK64k9SqPXe31mC3vJIXqvOG5c+qhLRbHmj18lqptO/k+qgvxFLk77tji8sjG8NiPKFwmitGqMjNmQvLiR814eTRSYdWiZ/laZ/yCerDC22O292vXLbRCmWECISjeRvcyevrOmE/nAIAgwIxVPgM4MA5/cW49VDUwlR0KWbh6/hHa4zZhEoS2xTj8mW1pGGIkFvNxgdr8HVGou0uglvvk+saoz 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)(346002)(396003)(136003)(376002)(451199015)(46966006)(40470700004)(36840700001)(82740400003)(36860700001)(36756003)(86362001)(40480700001)(81166007)(356005)(70206006)(83380400001)(8676002)(4326008)(110136005)(70586007)(40460700003)(2876002)(41300700001)(426003)(54906003)(8936002)(6636002)(316002)(47076005)(478600001)(9686003)(186003)(336012)(5660300002)(55446002)(82310400005)(26005)(6666004)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2022 15:28:02.8475 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5707cb2e-4b71-4feb-8b54-08dabdafff74 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: DM6NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5906 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 | 37 +++++++++++++++++++- 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(+), 6 deletions(-) diff --git a/drivers/net/ethernet/sfc/mae.c b/drivers/net/ethernet/sfc/mae.c index cd014957a236..6dfcf87f9659 100644 --- a/drivers/net/ethernet/sfc/mae.c +++ b/drivers/net/ethernet/sfc/mae.c @@ -283,7 +283,14 @@ int efx_mae_match_check_caps(struct efx_nic *efx, mask_type_name(ingress_port_mask_type)); return rc; } - if (CHECK(RECIRC_ID, recirc_id)) + if (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 rc; return 0; } @@ -460,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 Thu Nov 3 15:27:29 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: 13030410 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 41868C4332F for ; Thu, 3 Nov 2022 15:28:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232245AbiKCP24 (ORCPT ); Thu, 3 Nov 2022 11:28:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232231AbiKCP2J (ORCPT ); Thu, 3 Nov 2022 11:28:09 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2056.outbound.protection.outlook.com [40.107.243.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27A6A1B783 for ; Thu, 3 Nov 2022 08:28:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e23kQmuU5xgOxH2Lca91Vom2BALs/6ZyZfustXDLd41gDbJ70BEBY1vs5b7hFPdoVRbdRGqpGidYQnV8YZvWgn6g9YMLvi/aNDG5Ioz9Op74IDs0cpzXDeNe9DLZ2mHsW0II0IlVhf8eXQPgJbeLhQ0//0RZcxvx0TvoAlPtAFeloFpdNMWGjroT7tvK/EsjsCYkyTxKpupLDyCLyo/6Q1zEQu2tJd2E5YPu3sZ9DqJCWTgK+cUqstjw4tb3IwmFw+rwGUr6TnlPBL0dwNA3y4EYm/J6elxnXNVJPI16Ahptk/eoZxda6NCOfbqIRZTikmOw9xPybMVzFRSjt3tlgQ== 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=X0X5bMrW2EGgpt/ybTTdP45hLukAHCAfc2T06tzRA/c=; b=iRP8WAJ/ZU0rAUcPM+jn0sPfRi43qnUni2xPkocv8PFq5OnZSTCsu+pXfxwtQdmdQ/lBeLYl24tnJtq9DYM23vHw1xdWm8q1w7SgiZHfMEqozsaf2+wN8kuS/bQZ9UFJUzCB3ecbOJUWm0fvuAGRr3RdJLb+f3VzpmdVy2phtLy8nFLSbVMcGi73MlcNsConfdo8o93AgitD/Q3dSMe5qkMStSIgjwCund7PWmPeUZ8WDThKXW5xo01J3p1F1HxQjYwq7vJs5GV4OoPm684dDObabLsHaUOxJ47kv/HTLjlqryKNtAu4EMYg2m+7lNb9oO8J/M/bbCfmP6AFghnOnA== 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=X0X5bMrW2EGgpt/ybTTdP45hLukAHCAfc2T06tzRA/c=; b=Gf8r2diDgH8MjdcUQ1cZx+jhPt1cBu2LNJBZKNXrnQ1xo07tuSHvYKEM6C9D9XRxwQTDkD+EjLsXPjyo8rml2XDXNZkQRrfvvCdiW1rTgVP0EKC9JTIRJKxUwRu1efrdl4jnIYb3FX2jYTKsTXEXpzQFxfspNKeR0qQ+I8ziqPE= Received: from DS7P222CA0018.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::33) by PH7PR12MB6695.namprd12.prod.outlook.com (2603:10b6:510:1b2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.22; Thu, 3 Nov 2022 15:28:05 +0000 Received: from DM6NAM11FT082.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2e:cafe::87) by DS7P222CA0018.outlook.office365.com (2603:10b6:8:2e::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.22 via Frontend Transport; Thu, 3 Nov 2022 15:28:05 +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 DM6NAM11FT082.mail.protection.outlook.com (10.13.173.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5791.20 via Frontend Transport; Thu, 3 Nov 2022 15:28:05 +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; Thu, 3 Nov 2022 10:28:04 -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; Thu, 3 Nov 2022 10:28:03 -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; Thu, 3 Nov 2022 10:28:02 -0500 From: To: , CC: , , , , , Edward Cree Subject: [PATCH v2 net-next 3/5] sfc: add Layer 3 matches to ef100 TC offload Date: Thu, 3 Nov 2022 15:27:29 +0000 Message-ID: <415e8d4a16c22d8e8ec94ffa829c894a3651e3e1.1667412458.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: DM6NAM11FT082:EE_|PH7PR12MB6695:EE_ X-MS-Office365-Filtering-Correlation-Id: 532fafb7-2d4b-406e-f041-08dabdb00109 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JuHtOpy57BYUwBS05w+frSdOmy5FvR07vjHd5oKTbFzTaWyDq0MZfUhE3L2etlhGmCLhlbLyvkfgASevkzasyz2vRgVqAFUqlsQpsqSSvkl47dpgojwoUcvUs8t2iO9HtAjSAQRdpBbrfWyBUSdbCDfsCTTqvZr7WMrSKQHtDWvZlXF0+ox1wLOFy7kuq17gkmRPth+P/m0oADpsW/vsmsBGxh89YIJN8CH6v4yYYFdb/kSsjQYJZ7Y7WCkdt8cS53NQtGfa+YJcfKmdqloVX4HVQXVaMQyCnAuFiI+VUsjaIpvvD68Y8uGeJTvuAfhtN93CoKShsVl4cyHkpBTSDMMXwmlXaBMD7g+4a6YTeXCwQl/DunU3YXf2zMH0nH/uuoF9jlkRt7oMO35YuGrBwW9iQ6uO8BZgdO81dFnfmHuyp5zNtuqgxieisg7bcZ2vDUPW4oWd8A49/5fXwFMlqHRW8BJFEZvZtO17Cl98RN6f82FCwvJ0NHosYUc8OYyKS4VCtQpOtelr57nnL3rtn1x9F+6OD0M9W1KB0S/ZfwtsSrK+cj8XvaIGaDGRtj17G2LGgqMc+qp6CKVFpbsb+uqvnAwpwwU7XgmVwVLoqI8LbSdQAWnKVC3gND4WnLbHVm2ft15y8FNrYnjLBKQLMX6+3i+aNPXX9dNAqu6M21Rg1nmN/+Q5JZoUNkg6vODLMiaG3XrRVkQ0KYvT2E3fZmVR0e0LN5eIfMxujMrNg1LdbWe/8noMgLHGaqkad+DnbA5U3XlEPUQGBRjaeA58RQ5PUXGgXWImIYwCt4RBQuc= 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)(39860400002)(346002)(396003)(136003)(451199015)(40470700004)(46966006)(36840700001)(36756003)(81166007)(356005)(36860700001)(82740400003)(5660300002)(2876002)(2906002)(86362001)(55446002)(47076005)(426003)(83380400001)(40460700003)(336012)(9686003)(6636002)(6666004)(26005)(110136005)(478600001)(40480700001)(70586007)(316002)(54906003)(41300700001)(186003)(8676002)(70206006)(8936002)(4326008)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2022 15:28:05.4731 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 532fafb7-2d4b-406e-f041-08dabdb00109 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: DM6NAM11FT082.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6695 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 6dfcf87f9659..b894fc658867 100644 --- a/drivers/net/ethernet/sfc/mae.c +++ b/drivers/net/ethernet/sfc/mae.c @@ -290,6 +290,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 rc; 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 Thu Nov 3 15:27:30 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: 13030411 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 033FAC4332F for ; Thu, 3 Nov 2022 15:29:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231458AbiKCP26 (ORCPT ); Thu, 3 Nov 2022 11:28:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232234AbiKCP2J (ORCPT ); Thu, 3 Nov 2022 11:28:09 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2089.outbound.protection.outlook.com [40.107.223.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E247D1B9D1 for ; Thu, 3 Nov 2022 08:28:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LkvPlX24kWpjh5n21VjAMtr2YOXyUfdeeYeVR6IoYeRyF39TTXR4dPp3DkDMIvZ0T4FpFY4cSAEG+sRCK1UHGtSkaXPL/sw8nkVS6soa84LNh24vm9f9t5ohtbteeXvtLmbbUcCz6GbPUl70pbudrlSIWsf6C9wc//+j2iNUs1HTw7hQU2wAMkMeXg7I9Iv3Mi/oT0skFvV9QJOxACNIZAehphLn6CDOEc98IbQ2ea8URTkOl8E031T9VbQr1Y3//cKpW2wh4XI6AnANteE575GQGKxviXOg/M6nSK7OQAI1vF5G729kfDHXNMP9CvA3RKPwVxmNl91vnDHNZd1VSg== 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=RdBf05axzOIrSp5vNjVFrX/2eGJ6ElRZxq1GmFdNSgQ=; b=BwnHZvjDKE5zA9yHrFaQ2ESHf54WXs/5zT5rn7W2G2E5t7AeknRo3r2NESttqmWUJsVCGqshei4nTZUiJ2PtVfmytXWSt0qG1bvTw8GJz/pI2VT4nfolEWPNEEBTqc4DDUo3I7Mb+yQnxXfKWVoTi9ErtAAREf0zWZzQMPtAs0c7bYKii0OlKAca3SFK6ksGn9d2Vi1cG0hD4pVh0d6nBIScXjzou+Qr+B1cVd8AYiQDbew5GDos+QMaFDpJ3AjfCu2be2zUH8Eq3hWo6S/pfikaT2YVtLkMV73FsPjhOgbHIMqFzjL0QmlXUnW532d65Q7DL3A43o/ojDfU8Ek3UA== 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=RdBf05axzOIrSp5vNjVFrX/2eGJ6ElRZxq1GmFdNSgQ=; b=KPzKbvU66AD3YIA6ZN5k6mA97oKQxN1BNvZU+o13ttKfbgeU5g3daTU9XdmL6JsfHn8IblUHwxbvqXreYhezcOxj4lRLPQYBJYNOGBbZyY4vB38OdjOQiKX/lPP5dXrqiMqk3cOavDU+karowOv3ExMJ7Sq/X+V1P3I33HGyrVc= Received: from DS7P222CA0020.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::16) by IA0PR12MB8086.namprd12.prod.outlook.com (2603:10b6:208:403::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.19; Thu, 3 Nov 2022 15:28:06 +0000 Received: from DM6NAM11FT082.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2e:cafe::28) by DS7P222CA0020.outlook.office365.com (2603:10b6:8:2e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.22 via Frontend Transport; Thu, 3 Nov 2022 15:28:06 +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 DM6NAM11FT082.mail.protection.outlook.com (10.13.173.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5791.20 via Frontend Transport; Thu, 3 Nov 2022 15:28:06 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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; Thu, 3 Nov 2022 10:28:05 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 3 Nov 2022 08:28:05 -0700 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; Thu, 3 Nov 2022 10:28:03 -0500 From: To: , CC: , , , , , Edward Cree Subject: [PATCH v2 net-next 4/5] sfc: add Layer 3 flag matches to ef100 TC offload Date: Thu, 3 Nov 2022 15:27:30 +0000 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: DM6NAM11FT082:EE_|IA0PR12MB8086:EE_ X-MS-Office365-Filtering-Correlation-Id: 328e22c4-cf0e-475f-4aa0-08dabdb00188 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z9n7kk1u6g70XqRXz7r9mgjgKJTWOZGyHdSLyHyY7e4pEDjtJNijTwLLuP/tfZ5YUiCPPF9U+Vafuj4i33OZml9i2XCH5kP5M2ZQ+y/MNcXxo3PxAbA2H4Uz8AsSObyuToq4iMcpsyAuBjkMpo3VItxL2wCKjSK3eUiyXVLWP/KOvfyrjK1/cigk9foSfwXJysMSqXHofQZ5VWGmPTHPfQj7YxL/isKBBM23i4eJOqEPQeJNoyu6qKvPCXVfJUQO5ajZLz/2TzdQpMFpJQpf6C3GXiIQlXNCm8/RtwxMipyVVr50e6QuhTSmxkm6ahE82Ao2u1jSK0DXtiVh3KeKgkDxr7whwoRAy7/njPqdrcr0lfS7WdDIMrwysg0id1V4ErrTvo4YGYgpCGhCrZfVSTe8ynXpaauDpuhX7gV8LUaQh4b8yCyRFGp2aH7XInZJQMUJ3+M0kSFlNgxDrwaYx/h9htyDBMTTsePhj8eu66Re1ATM3MPdl5HFcXE+6gN5DY0si8/wNk0wrkQe/m2W7EknOlN88m0Bhkdw/qewM+x0Mdfpu2vunfuWLWJWFIbv3xzxEiivcc16tUzkdlepnyFSWlLr8Sn+voYhMqZ0BJa3Yw8yEPI0QVp8yReksdyj07a2JP43UbGSnHlyHtLVo8lCEmmkEV3KqjEliyv/7mR2J4jXrtnowaDoEPQN11FBTpz72BABxVdCkfC9eNmqRa9DWWzZUWHlR8PCYTVvKzfCiC6rhQpqIZqZhZ5gN6ZMdlAFuN1PY1pNqCquDZPxMLv2mTH4qnp/uwvHDPp+zZUr8NRIhrledIcPEh9y1h1J 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)(396003)(376002)(346002)(136003)(39860400002)(451199015)(46966006)(40470700004)(36840700001)(81166007)(36756003)(82310400005)(70206006)(41300700001)(47076005)(316002)(5660300002)(40460700003)(40480700001)(8936002)(110136005)(6636002)(2876002)(2906002)(54906003)(70586007)(9686003)(26005)(83380400001)(4326008)(186003)(356005)(82740400003)(336012)(478600001)(36860700001)(86362001)(55446002)(426003)(6666004)(8676002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2022 15:28:06.3168 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 328e22c4-cf0e-475f-4aa0-08dabdb00188 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: DM6NAM11FT082.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8086 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 | 25 +++++++++++++++++++++++++ drivers/net/ethernet/sfc/tc.c | 10 +++++++++- drivers/net/ethernet/sfc/tc.h | 1 + 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/sfc/mae.c b/drivers/net/ethernet/sfc/mae.c index b894fc658867..e24436ba699c 100644 --- a/drivers/net/ethernet/sfc/mae.c +++ b/drivers/net/ethernet/sfc/mae.c @@ -263,6 +263,18 @@ static int efx_mae_match_check_cap_typ(u8 support, enum mask_type typ) mask_type_name(typ), #_field); \ rc; \ }) +/* Booleans need special handling */ +#define CHECK_BIT(_mcdi, _field) ({ \ + 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); \ + rc; \ +}) int efx_mae_match_check_caps(struct efx_nic *efx, const struct efx_tc_match_fields *mask, @@ -299,10 +311,13 @@ 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 rc; return 0; } +#undef CHECK_BIT #undef CHECK static bool efx_mae_asl_id(u32 id) @@ -472,6 +487,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 Thu Nov 3 15:27:31 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: 13030412 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 D846AC433FE for ; Thu, 3 Nov 2022 15:29:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232234AbiKCP3B (ORCPT ); Thu, 3 Nov 2022 11:29:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232235AbiKCP2K (ORCPT ); Thu, 3 Nov 2022 11:28:10 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2073.outbound.protection.outlook.com [40.107.93.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F3A31B9F2 for ; Thu, 3 Nov 2022 08:28:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AoWC9e+PDhwSCeQiYxkOwGhGRdIvD/hC3MWdeI0aoI2rgDwBNMo4d1NtCLzEoCWIr1xUizpxvZywRW6oHPlzI+xdZipMywTKaCWlkPuDXnmEEnNmB08q+kD2NOA78Rw/+nzuiejhMHpcoeIkgKls5MAqYNA23APhnXJvHKKBbGAQJvr0aebdqCoZdqRdLNN8GpFw7HVsKu85zrnmojfaQtd5pA/yssfR0SXT98RoGU6BcBkjEz/MGFH4amS5mp0bFn1RdO0Z/MqXgjfgUy5wY41DXR5XyV5XOdI9MBItWSyZ8h+3uKdtSjBDOPv6CClZ9Rg3vk23NdTOllfUJh7oyA== 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=paOFrwP8qlnxk1MkOis5EPY4kXJciQxx6UMYE3uMSkM=; b=aiNw7h20f5e8gUZ1pXUysekhwYUC/vt/ZlqVZScymIF3qdf/VoLI+QJVoMi4JZjJ+EGcH47BfNoSBBj2ErjKP1Ayrb7PUEbnjzyQaZgawg30ID9M/L+y5nSoxjYy45hNrwwam97IhbOZkyKvSdkvLEDEXdqrNQk14gSCVQcHJVRNxsNHpQD0kd0R8GC9He/uQ0RFWzC0Kw+4fkcRrMgeBi/k9bFj0u8A6jDK+Gp2PSoePo7hPKKk2TDUm2OXmClLPFWTFTPRuyPoPagpCH8WW8kHIw2ennXyRftxACajU0sS+aJY7nz8jXeMnFM+fkFp5lxavUErnKryEuWlf3pBKQ== 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=paOFrwP8qlnxk1MkOis5EPY4kXJciQxx6UMYE3uMSkM=; b=O/8fNoe9YKg51GBrp1g9XaReikzBT5QT4t+nw8NjYihZYaRhEREWZi9sAXa4SNFhe4X/TLi2V1ZhgfaP4HfvtDkwSS/q2PAdBN0QKLVok/LRO7bzYRxhW9yL44/oqnlyaIwoLZ3TOiFW6ampiXN7Ok4uN8FRonhhuAiUU6Ewc4g= Received: from DS7PR03CA0017.namprd03.prod.outlook.com (2603:10b6:5:3b8::22) by SA0PR12MB4464.namprd12.prod.outlook.com (2603:10b6:806:9f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.22; Thu, 3 Nov 2022 15:28:07 +0000 Received: from DM6NAM11FT076.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b8:cafe::88) by DS7PR03CA0017.outlook.office365.com (2603:10b6:5:3b8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.22 via Frontend Transport; Thu, 3 Nov 2022 15:28:07 +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 DM6NAM11FT076.mail.protection.outlook.com (10.13.173.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5791.20 via Frontend Transport; Thu, 3 Nov 2022 15:28:07 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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; Thu, 3 Nov 2022 10:28:06 -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; Thu, 3 Nov 2022 10:28:06 -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; Thu, 3 Nov 2022 10:28:05 -0500 From: To: , CC: , , , , , Edward Cree Subject: [PATCH v2 net-next 5/5] sfc: add Layer 4 matches to ef100 TC offload Date: Thu, 3 Nov 2022 15:27:31 +0000 Message-ID: <2ca1b54f62eb030a98ad94b9709e95fc39b29351.1667412458.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: DM6NAM11FT076:EE_|SA0PR12MB4464:EE_ X-MS-Office365-Filtering-Correlation-Id: bd99c55e-eb51-4fb7-e4b4-08dabdb0021d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IHb4NF+OLclTXkfqqPHeLb0XcSvs6/xO/7daSANNHKn+gYroYPltC25K5X9vZNYVrN1um0ld8fUFslLn72ifuKqWJqlJutPjXVs+We1r8KQOpu0zF+IP5ZTTHmoF7eMO3ItJm5z8MxWwPKwk67Miye8Bu4FxWbd9IrbbgOUGaMcSd8oNGxGv6pKZYyDQZ4aQdeI6Ql1wrg27ZzkWxsGzExu8bsV///ZKo5o5hHYQRK6zdKMg5QA63U65wZBn+gO8DU3MS2JEEVD4fkZ0C7+PO9vL9yrfZvZu5bEQU6PTWkqhwnfwEYHA3Fjq1nVYgs9Xr9hw5DfEj5RTCTPAaQv368Z5xz6905WqYwQgALDcv8k45KB6A0P3/w/1eNqu1tLrHnx1um8vvx3uYylVV8+jRPOoMnqiCbFXojHvwDA3V82wJ3NxHF+bqfN2AmitOmEKJlhoR99DXY6pKzLV0Hdtj6w7JmPx5/fAgtPiCMmCx/0lEM/390GjDyXK765RQUa+08kHDLflo0+noaukru6sHOV2Ej2xc5YRGH8L97a8BnlSaX1aL1hFttLx7AvAeY2Cl6f67EdSiTzlbbE7sswJfZXBcC5BmhBnswG5kvc9FZX9ZXTl/J0A4gUy0JTFzFbcgzj/dUt2xO3/XXlq2ztwvGpx5Jb6qSL6oro1T0vV5vXfcobhrVNcK8CJd6RsNWzBdHfZYV7UJ/QFLnV0H3Kr9cKW3Azx8+OjmJh7rXLsGrrlc6eA5CKRbbq1BnAtM2b/teK4I+tmQJ5jvla1GYWuRn/M+A/Vqm6cx0cqISzQ93Y2yksoMUxXQ9wDdHdLMIgi 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)(136003)(396003)(346002)(39860400002)(376002)(451199015)(36840700001)(40470700004)(46966006)(478600001)(9686003)(26005)(5660300002)(336012)(186003)(41300700001)(8936002)(83380400001)(316002)(47076005)(2876002)(40480700001)(6666004)(4326008)(8676002)(426003)(2906002)(6636002)(36756003)(70206006)(70586007)(36860700001)(356005)(81166007)(82740400003)(40460700003)(82310400005)(110136005)(86362001)(55446002)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2022 15:28:07.2816 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd99c55e-eb51-4fb7-e4b4-08dabdb0021d 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: DM6NAM11FT076.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4464 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 e24436ba699c..1e605e2a08c5 100644 --- a/drivers/net/ethernet/sfc/mae.c +++ b/drivers/net/ethernet/sfc/mae.c @@ -311,6 +311,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)) @@ -559,6 +562,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 {