From patchwork Thu Sep 28 08:44:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13402286 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6484B1A5BC for ; Thu, 28 Sep 2023 08:46:22 +0000 (UTC) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2073.outbound.protection.outlook.com [40.107.14.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEF4D1A3; Thu, 28 Sep 2023 01:46:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OK3jRGoYb7nDSMzVelo77cgnfDD1ie2Cz4bhiZkMKUODoBYdKALgi5m4moPDek/wKaeKiZ6pDIh0xYVMledXiLiNl+2zHz+tQpy519ECYDdiuGGMeCBl7msaxhL3Mek3FZX8EMZXzmxKQQmYD2ry8pb9ILTO9xJdzlij/y3a16Dnk5IbvSWAU5X61ds5lMPfYq631nPVAfLRxnFnO5LWZ8eP0e+iMD/Jqabisy438bXj+12KY7leOMSkt/1RgR8gbipAiAprCR13ogVb1T+H76k54/YViLdvszHLIgVOnaKjX8XMztpP6wI0nF+OMNDEnTcU8Zk4Xd4GFRnI0Ap6OQ== 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=kqJOThX61V7em4Tl2L3PoPhdRutUFGXNAxIZvKCj+NU=; b=a6+9Usdvyz7MBpcvLP8XHNsEeDy3wDxOLgSSZ9bpMWsMONErO/jwe/C1v1DBWb0fzFQeLH7jLeAgiamI5xrDIDjrG/6n4BuBSCSjzDiGl2HOso2mf5EMRu5FawrkRtXi2l26NYiJXPFX4eG8+SFYOxKkzWRVx98jI34NQ4C9CJ4pDEU6fUro4xminQoxi9gDkEA+FcgWKL1+IM+1VgSA52aYiohLrgAsSDAi+yJtOAu7/D7FcyPhqItUA+RoXqb7+K3rJ40aOOFQ+mMD8bfLBt8f+rGQ5lClj990rAZvnaOoxWMF5toCwQxZpdbrZ5sA6VDq4RRAb1m2FpsqDuOfvw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kqJOThX61V7em4Tl2L3PoPhdRutUFGXNAxIZvKCj+NU=; b=dOqS4s1BxRUj8gfeSpawkIB4oqe8a5q0VVfZwGTiFnPSwbIZIpSKvLz2mi1rruMonr9eA8rLlr+vFlMxWif5Y/wNhAlfrAAI7QfQZtQgq3j4ojYKgmiqLVYfEaXzcopNh6W1bXLnBvkNjOckW8Au6lg1WMxEue6kv0mE6ftRWaE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AS8PR04MB8514.eurprd04.prod.outlook.com (2603:10a6:20b:341::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 08:46:18 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617%7]) with mapi id 15.20.6813.027; Thu, 28 Sep 2023 08:46:18 +0000 From: "Radu Pirea (NXP OSS)" To: sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com, hkelam@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, borisp@nvidia.com, saeedm@nvidia.com, leon@kernel.org, sd@queasysnail.net, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, richardcochran@gmail.com, sebastian.tobuschat@oss.nxp.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v6 01/10] net: macsec: move sci_to_cpu to macsec header Date: Thu, 28 Sep 2023 11:44:21 +0300 Message-Id: <20230928084430.1882670-2-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> References: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1P190CA0018.EURP190.PROD.OUTLOOK.COM (2603:10a6:802:2b::31) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AS8PR04MB8514:EE_ X-MS-Office365-Filtering-Correlation-Id: 837957ae-4a9e-484e-3db6-08dbbfff5da5 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: elePA4PQlGikRBRK3I6mcXehtXLpseMza2FEbNfWIifVSTGot7Bkve+M93kG2l5ZLCBLLJA7ud4gsL5z+nynPcvHUq7akgHhWGy9wz+v1nrH2LMPNxt9fHXOVNoxHNJRvKcLpYdqEKq11zg5hwNr9pH6zADRWlfIOKvv7yAuJxh+DaS+5aAF65xnrmjH2bbg879BpnHEm47P02gJUiUkxzh0M4gLpcTTnzcregn7FCIcm77ULIEe7KcgprhPeqoTXctvjQkvSsFJxrMpAc2utfeEWmcQuop9X6ujYA1xACogOL6w6qENR8wL4AGEUEpxlamm48gXeoF2vWO46Us79NiAZQS6CFS2f2B0xT+qINZNTHJg+ml4fnTMzeRttzRO5S+3HKNc6VNh95F4kL/tii34kEVJELkXiUW2A6Bv/ej//DvgCj5mncJGeiv3UeOxc1QMPpm9tpl9jL7/tAz2uMwVYjStweguHK2ZUnHDhPfasykIql4o8HV/YJ43FayLlSFxqfhEk9h5Q8rHXIhR/1yCw4hrjWmBEL5YmX2iwfOe3YAhvztNJVoO9W7w0YYFztu+ndju9aYE3upGm5KdYQIPEYaIMvyrofCH3hQ4ikZPr0mFxV56gdGCNVdBhp+IKZAzTF9wZQFCEgUsikqf2g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(366004)(396003)(346002)(376002)(39860400002)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(6506007)(26005)(66476007)(66556008)(6666004)(86362001)(52116002)(1076003)(6512007)(6486002)(478600001)(2906002)(38350700002)(38100700002)(83380400001)(7416002)(316002)(8936002)(5660300002)(4326008)(2616005)(66946007)(8676002)(921005)(6636002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: m4CCBy4Qa2IVRHPMPTv1Hyq+HIeCVL7AK5beU4JYjKJZ3PtSDbi9BIaX0n4f9GuiB3Na0vUzeB6nCyBkOtuJJJI9AicpDVgy6BDHH88CQ/6Sv1W7hIU/H/ux81Jz5N7R8zlp7tXSjU97pyotVvyXFmPOMBIghEw3AfUnH8eXgrsYh/pEAxgKDmCwXeKN1G60Ceryrvo4k2Mm3w2lECu6fN4KddDa88VM1SbCCflsGJF0879e+03CMjJDoYa+hM/le97pwyLidP/5iXdJtbHjdXdVVP0dG468LsituP/CKc+ZYamBjIOWW8tyR3sQN4MWsNUpaj8FYMjCECBvSCZCPuoXD9hznGLwZgb4J0K2So2NsY/aZZAsrmQhtd4cUw85wq5quTAfUHpWQurz9nI1gvjb9cmK+E/Vo9mBkt+E3lAchNO1zuy3GZ8lUxWUrLhe+8odNrU+8mQ+R3gB0C589dObSrDE34f/M00K+IpSj2e0RaTrd5i2NxnwHnEOgGlENUWbtRhH/50QXoMj+kvZP4lj6tY1gk7yHClrQM4TWej8jqvcSRAXqXiJZCHBDjrG6sNRoG800OhEE4YxvuWWWoV5crTHWKRmZzMSRw/+WY4IDW8cf64FlMu+UKXj2gpJSLELMeGVWd4e/Jq7SS7LuVn+/Q7BFUScOWsStubEKMTkAaq4LxW+xB/aateLXWQIan+9F+yZ3AoC7cEP1dCrEBodcHXNAqCbsN3/dj7ik9FBp4m+SnJHVOHzmEA19z7q2P6Yb5YugPs76ivXjABrZkLElM++BrKbG/vmFpdrZD+YRyru+VuQ5qsV0kHeTONe2DpAomxAj7gCnpJCZgKXVg+aNr1+3uK62yr2f64yxr25T+YFz3hXymJHnOWyfaJwMvcDfhnGFiUD4uo7/Go1ziFsQq3SYS2KzgIL2t24/6F8A+LTxBzzja6fpdq1dlIrwpCi0+heA4Ozrm6v1WTERXMYAvNf6BVYtnI0zk6oMi+I9v2FKq2DWoAxj5U6k6HpssU/+5u4+JxvRNYMcJUR1HIWDPgDyRr2beHQeitaczdpD3g9konF2Yiy6/3zFeU+1nLiV/uyObAChxIZp6VQl1OsedcJHIK2CdiZYWJao2dkIVTYdbr20qFH2ajyYptLo6EEDrHJ49W8wtykF2Sx1ErdDFXE+L0HP0Prh/rnA4w33Wqn5M+XhqvZnv315xhsP68/MtjsE0Z14pRLMXoU9qucQAZaTnpfpT5OJJKUOivq85pTTd3ilpI8mCeuhpuUOKZFu/qGavAA9hes2NzZlQlJhpL2MehGbmIOksuO17U42Q5qkJy8xBIcTP1z8Y6PepE8Bpv/LhJdTlDSgsvxVui6xJpwVee6+w17T1pVGC8c18JNHjYR8s7zUAoALV9++F2xueg8VtUwOgYq710z8aiQFoKHGKJRCmOqrlYWl7l9I77I011k9xZzyxlkUfUvQPEP3OIXMPLaYV5hNXCEctMV6ar/vxcT52pHK4vcm+GvsTfgbRcfHpPwjhFLmoRvQ2IAjawDH+2ST7hPwYCobv5hiz+0HhAn1QOMIErkAq83TYXFeouU0FnENWMWFQsyD1MpFqmRiYxsxuXNG957eg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 837957ae-4a9e-484e-3db6-08dbbfff5da5 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 08:46:11.3569 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Jeo6J5C/HRW2MUV5pZoTBfi0uy7cItbSVHkLZom1cm5XCoULFoz9LIE6zWucqXR0TF4ThXPDAMxXFNc9+XqCVnNGLrENv89MrI0a5mWfrMI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8514 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Move sci_to_cpu to the MACsec header to use it in drivers. Signed-off-by: Radu Pirea (NXP OSS) --- Changes in v6: - none Changes in v5: - none Changes in v4: - none Changes in v3: - patch added in v3 drivers/net/netdevsim/macsec.c | 5 ----- include/net/macsec.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/netdevsim/macsec.c b/drivers/net/netdevsim/macsec.c index 0d5f50430dd3..aa007b1e4b78 100644 --- a/drivers/net/netdevsim/macsec.c +++ b/drivers/net/netdevsim/macsec.c @@ -3,11 +3,6 @@ #include #include "netdevsim.h" -static inline u64 sci_to_cpu(sci_t sci) -{ - return be64_to_cpu((__force __be64)sci); -} - static int nsim_macsec_find_secy(struct netdevsim *ns, sci_t sci) { int i; diff --git a/include/net/macsec.h b/include/net/macsec.h index 75a6f4863c83..75216efe4818 100644 --- a/include/net/macsec.h +++ b/include/net/macsec.h @@ -324,4 +324,9 @@ static inline void *macsec_netdev_priv(const struct net_device *dev) return netdev_priv(dev); } +static inline u64 sci_to_cpu(sci_t sci) +{ + return be64_to_cpu((__force __be64)sci); +} + #endif /* _NET_MACSEC_H_ */ From patchwork Thu Sep 28 08:44:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13402287 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D14B2587 for ; Thu, 28 Sep 2023 08:46:46 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2085.outbound.protection.outlook.com [40.107.21.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFA43198; Thu, 28 Sep 2023 01:46:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cx2BcfVpqT5VnUrKg5I9oBU1eyoL6ZJwDW6/HELlwPlGMNoFP6SRiuFS3RCTCFig3pCM1/BSYuCudPaA0I5jXtykeUErRCI4YdRX358kavuWOzR0yitCHLKXc3YKaIOkQC4IdO/kpp2CuePZa0Q6k+dwXs1HhUYXDHGWUrF2NDYS3ctn7xav2YnAldJO9pNWHJz/3RBgFH7X1nTT4McuISyGsj0ndLkUYZv6hvIYQGsXN/JPGaXjNTi2vA3SdAuyy+cMTlHZPAYh58pj1xqObowJQKwae3qPw2FEFnlU1YrHsfZdY/JBg+nsywiz8qVG31eMpo5GvCzZfaEvTgvSBw== 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=McNT4W0p/+buOEGJAz5QBoS1T6lbeQuIcj0fqqjRD14=; b=YZVCo7heHIBp8HaVfSWJzQ/KsDUBntN8rp8KuIm6iZOVXr2sLD14B416C5KOvZ8pq1tb5NFEKm00ymxWvcUQ7s2ssGCM+6Y8r407vz3kOZbolkj2S7/KjbFAsNWELFdH60hAsEILrHThTUvas7Jft2iWWje9WQHUyVx1/I+4JTARb/e25aRuYVUEdkgQP6sdjbFk2wd0XNFJoBwFMaJy4J6CDB+dTkY7iZBC4NHNFiS5kezzGkIsErfwgef4oS6rePDzGymL3GW2bYN9878fzqEEe1LhtpMAloHD6PkzGR9upMT97VP1dirKj03PyQ48EBOmESTcCbj4BmXN8Qcncw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=McNT4W0p/+buOEGJAz5QBoS1T6lbeQuIcj0fqqjRD14=; b=Yg7m3Atwwg+3b1EvOrMmFxXwr547j7ghwAgCOdFfzlOAR/VAsPxlpEuGQLRuTTnSGB6jdY3awDP8s11zlNXvfAvZ3o2+KlmIg47U6GWSYvfP9wH5j5bcJUh5zgylewult31FrknOikpKuT7E5tUr1lqZPIFam58OrLZ6hkmetOs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by PAXPR04MB8475.eurprd04.prod.outlook.com (2603:10a6:102:1de::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 08:46:41 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617%7]) with mapi id 15.20.6813.027; Thu, 28 Sep 2023 08:46:41 +0000 From: "Radu Pirea (NXP OSS)" To: sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com, hkelam@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, borisp@nvidia.com, saeedm@nvidia.com, leon@kernel.org, sd@queasysnail.net, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, richardcochran@gmail.com, sebastian.tobuschat@oss.nxp.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v6 02/10] net: macsec: documentation for macsec_context and macsec_ops Date: Thu, 28 Sep 2023 11:44:22 +0300 Message-Id: <20230928084430.1882670-3-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> References: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1P190CA0018.EURP190.PROD.OUTLOOK.COM (2603:10a6:802:2b::31) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|PAXPR04MB8475:EE_ X-MS-Office365-Filtering-Correlation-Id: e88797f1-3f8c-482f-6229-08dbbfff67c4 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UqRIhAGT427BvCE8mpxW3tRjSUSZ7wf2H5orXAHI4QX/+59WMHexV5w8YtGlQcPVNRo+cDBMwWWMhcBZ2iCZ1QTwXixxaZfWlM3g82By3NypQaKkx0LRbz8/19wtaCJlQ60UFWfZtdtslccoikdHVoBYS7IBT/xIaLCAjzzIu4NYDBQ5po+X7q0j6EABzRTTYn4hOcez19m/NdOCLwKcl0slWfu64cFYcnF9bM5GY3b+Ir6Xy0GVYYmoWQoaLDLK7HNO4MPnJG2ZZvzo+Zi7aQPxND8vDkR3ZcTFqJRdn5j7nubOSuGqW3juGZzF6Au4Y9GlGu9qOFWMnCS8CWCmUrJrHltPNcRfFFloeQ+hEVa+AQRO4pxFPSakQBQlxMTEwPDe4fOjouedl+ywLWd1KzNiKjWAdL3RTeo4lWFYyfKQuU/755O8BFRG6XUj1/U/GmPoybvzh/PHOl+xqfnFWoHh0QRyv11UBnZmwdSN5XZZmNh4dNrzmjIlKtRDNRF1VDHTjHXs7N2YteFaKZuXgMHwQfXlfBKbHFLpMd9VAnrz3og05S3ugXxCSDn1ecOvH6eruO6o+jejlxECuCmmOH8vbiCoqiXcHGxO4qwKBdG/8Y4XcPMw7D2hjPEHnMu5vKyvi9b0l5sdeTCBNAtfsw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(376002)(136003)(346002)(39860400002)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(6636002)(52116002)(6666004)(6512007)(26005)(41300700001)(921005)(38350700002)(478600001)(38100700002)(316002)(2616005)(1076003)(83380400001)(5660300002)(66476007)(6486002)(6506007)(66556008)(8936002)(8676002)(4326008)(66946007)(2906002)(7416002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vvBpwrhxYmwicWkyyFq98/AKJsfJd6hp8Vk3W57CHOaiwQWO+l+ou3oVTxrYqVAgRgh59w4c/Ku9GMBN2D4hJ3POjn6FJn9fevClGEUmH5ZXnh8YgJaeqmocgxL1JrBmnBPllDmtcrfka2j3HeVTStZOn0CkkYEtxqzlEc38AgF9ZVpJC7DITDTlLKa2aTr3FUdO7VxY8QI5OZdwLUsZtCSQpJY/BFxJQ+qy+k/hjYxTvPDpBGSHhcxAqbC0Okj04ffHaV/RV6D/tklJp6hx0Va/OBG6Q769Sesygp+MLOywBpCBafWf/Q7X+uU9lVuAjBLdWRlenYyl9EnQZkRCmRumngacJfW6sJp9ZOmyzSv9iy8FvoFRwrHz+iS01G+QkndZe4T9XUelg3AQry9xLxjfcsUISzmlLWq2aHDk6N+cxB2dWgZt7BXknu4MThVden9PY1+rp1kRJgolw+xcsbpCFi9Z50rqxo+adiTWQ4MVTSopXyWjxuAl7Nn8wSG4UEK3/c2yuuzwDUnSM+28p2igDYqHI4BczB02fz3ZqpotPSS7/waK/vvtwyaW05UX/MJJtlIDWyr8ultzOh7oUoUbwAHsMB2qYlkNEpYabu9jK6ufSPMFH5kzgRtlI4Yj8+7dsmq791J4ptavoDaIS9B/4FCWiHg+yzu+lCwGCEbzBKJumDiiQafIXv4WhMzzd59aRz1fsY4CUyx2VSAXPGRY91j8Po//7fgE6HgRaYu9ETK7aWvBCYEcdrUKoHKwCK+n9nAbeOvVu1duzFZW3oYLzlZgEg1GyTfIDwZpgcEVD1k2t9Updt54F0pdkwEKY2S0FxmXeBfs/edwt8EZUCNxu3o/FQYFPrQrP/Jd2EW7z+C/sMutWVqrdgP8MrxOMSj5/gneoqCV2mmHAp7927VzDrSonmz84GMEqGBTkC4sMbs1u2xtBi/sujc2NKwC50UmvdFyaJjmuq7GyOdq41y5a8piij122OPA4awtv+B1ht/rnib8EcRaGjxJm0lr1LfeyMuyFBAEmCuOlYMsDzOIOT0N7b4u6Qz/IVVnoIE+Eq09b2hQqCq92qondtCQBC0sb8QMbkHHED5vKU+zh5EC/yzyk9SQrdBu9ui+84degBqH/992y0Wxx3fLFOfIt2UYOehTqduMLBj61HMNqyUzOJ/W4wVo0f6laGfF37Zg01Q7srtJ/X1XTRWQnhmC1KkTIlNNGkA+r6aaYdkpNe+gB59kuWca6fRqtiBx5+aJ72szYL2Hs2u//doLwnDS8kLhC4CDgJtebfcR8R3xONoAAdhlszmIomXG4C74vQ3jl8v6Gbwp4DVG7AC4Cp5O3PGtICfpV//p/noRwPgutoYX5KM2UfDlfIr5o7hXrCsnpce06RMbvzWtTv2SkDYLLQcs8R6DLBlWqoiJNVSRHMbKfgGaZi2AM+SDfAyhoiKCv6CM2ox93eib5tlcnWZf31nSXqGU2eN9fSDotqf0/Zkfi9xeX58QQSK9spoI1bGaGCxse3n2PWLg7YWtdliP+0OrHgcUSIP2jqjEzH7IdOvIpYJ4U/ZQciDJUrUs+tq7yHjYbzkgixv8/Q0czjBMgfRxbc1ruPCKEKz04XD3Gg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e88797f1-3f8c-482f-6229-08dbbfff67c4 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 08:46:28.3515 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AWVdo8o0hraJb2jZZ8HA2YfEUT7UloZZH06OTW6y6AtlFyuxP8lgNcC+sOxZhPpbcBIoClmWQ+l2oAeElSFLcppitcEJk4zwIR5X6UfQt90= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8475 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add description for fields of struct macsec_context and struct macsec_ops. Signed-off-by: Radu Pirea (NXP OSS) --- Changes in v6: - none Changes in v5: - none Changes in v4: - none Changes in v3: - improved description for the netdev and phydev fields - fixed typo in mdo_get_rx_sc_stats description Changes in v2: - patch added in v2 include/net/macsec.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/include/net/macsec.h b/include/net/macsec.h index 75216efe4818..ecae5eeb021a 100644 --- a/include/net/macsec.h +++ b/include/net/macsec.h @@ -247,6 +247,22 @@ struct macsec_secy { /** * struct macsec_context - MACsec context for hardware offloading + * @netdev: a valid pointer to a struct net_device if @offload == + * MACSEC_OFFLOAD_MAC + * @phydev: a valid pointer to a struct phy_device if @offload == + * MACSEC_OFFLOAD_PHY + * @offload: MACsec offload status + * @secy: pointer to a MACsec SecY + * @rx_sc: pointer to a RX SC + * @assoc_num: association number of the target SA + * @key: key of the target SA + * @rx_sa: pointer to an RX SA if a RX SA is added/updated/removed + * @tx_sa: pointer to an TX SA if a TX SA is added/updated/removed + * @tx_sc_stats: pointer to TX SC stats structure + * @tx_sa_stats: pointer to TX SA stats structure + * @rx_sc_stats: pointer to RX SC stats structure + * @rx_sa_stats: pointer to RX SA stats structure + * @dev_stats: pointer to dev stats structure */ struct macsec_context { union { @@ -276,6 +292,28 @@ struct macsec_context { /** * struct macsec_ops - MACsec offloading operations + * @mdo_dev_open: called when the MACsec interface transitions to the up state + * @mdo_dev_stop: called when the MACsec interface transitions to the down + * state + * @mdo_add_secy: called when a new SecY is added + * @mdo_upd_secy: called when the SecY flags are changed or the MAC address of + * the MACsec interface is changed + * @mdo_del_secy: called when the hw offload is disabled or the MACsec + * interface is removed + * @mdo_add_rxsc: called when a new RX SC is added + * @mdo_upd_rxsc: called when a certain RX SC is updated + * @mdo_del_rxsc: called when a certain RX SC is removed + * @mdo_add_rxsa: called when a new RX SA is added + * @mdo_upd_rxsa: called when a certain RX SA is updated + * @mdo_del_rxsa: called when a certain RX SA is removed + * @mdo_add_txsa: called when a new TX SA is added + * @mdo_upd_txsa: called when a certain TX SA is updated + * @mdo_del_txsa: called when a certain TX SA is removed + * @mdo_get_dev_stats: called when dev stats are read + * @mdo_get_tx_sc_stats: called when TX SC stats are read + * @mdo_get_tx_sa_stats: called when TX SA stats are read + * @mdo_get_rx_sc_stats: called when RX SC stats are read + * @mdo_get_rx_sa_stats: called when RX SA stats are read */ struct macsec_ops { /* Device wide */ From patchwork Thu Sep 28 08:44:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13402288 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B57C6210EB for ; Thu, 28 Sep 2023 08:46:54 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2087.outbound.protection.outlook.com [40.107.21.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D0469C; Thu, 28 Sep 2023 01:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bm1EvonnixUEjFHvLymVcIlSQDfVYxZDGXOPy0C9ciQMioR5xSHsuRRfeR90hm1K3sVyT07OS5+rjdl0lLGUGSY47RkhF36vkgY5o8HRc8/Mw36DUjWvWiDlObzLPBwCnJzaEnI7g1IL3XDKcVGRxqGUw698ggEQXnRygs2oh2Ss/VdhF4Ofh8IVGnuLAvTSr178bshp+HF2PyTry9Nymjx97xuQXC3/4Lq29cUhf0sefRyGyM/VneQSIExFjl5r4GB+xtz8sIsAmSAQ5Ps83FrTswnjv34bw2sLJqh8H+LBXC2/Vr4UAe1Jz3rQKAvFkujEc+JfJIsobn9m7dGruA== 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=6O9ES834w+8WlI3OZppjlnFcdMIUBAc4K7SW5kEhwRc=; b=RWYWunRjeCCHh780umuokNsAbITMxR8juXxZTwo/yrBb0RkaQjzXKlfV9XDMIjpzXC01uEy4fGN58zRUBHypSsfaytHQIoNQgo+UF00+l7f/Sr/GV/ZLTxVEs2SjaGOOk2B0kh4trrYdp2rlWKUjkpjswzgelLa5ognMYMIUD9NWPhh2fqJjL9p0KLbLosdW2SP8Wkl7b10ZBCfnU/iPJN3bIQjTJJRY1DgH0AB6fqAc++PyU9m8gOUM4oJ/qkjiH/0M16dT6xXb0//RCcLq3w9ryhJb+J5yYkbq9rbRe8EwSsKbR+wZLdBjpKLp6S3+vXx9p3o00uDi1/jr7UAGgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6O9ES834w+8WlI3OZppjlnFcdMIUBAc4K7SW5kEhwRc=; b=FGs/EiOuUTuV19oOgx0/PTVagIDOOj7S7RX6Uf8a8twsP6T6YyprJ4l/BFteE0OZDHtj2lp2ecjblovPINJKXGnzcMkJcNq+NiKLw1QPXvKl0iYisV6LlLfFNUPV4BhnIWha/2MAQS41vnvPU2vumHVlHo3vzNJh4Q8ymFRgDwY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by PAXPR04MB8475.eurprd04.prod.outlook.com (2603:10a6:102:1de::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 08:46:50 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617%7]) with mapi id 15.20.6813.027; Thu, 28 Sep 2023 08:46:50 +0000 From: "Radu Pirea (NXP OSS)" To: sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com, hkelam@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, borisp@nvidia.com, saeedm@nvidia.com, leon@kernel.org, sd@queasysnail.net, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, richardcochran@gmail.com, sebastian.tobuschat@oss.nxp.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v6 03/10] net: macsec: indicate next pn update when offloading Date: Thu, 28 Sep 2023 11:44:23 +0300 Message-Id: <20230928084430.1882670-4-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> References: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1P190CA0018.EURP190.PROD.OUTLOOK.COM (2603:10a6:802:2b::31) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|PAXPR04MB8475:EE_ X-MS-Office365-Filtering-Correlation-Id: 73d56853-3f4e-46e1-4b0d-08dbbfff71e8 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vT38auWvH54DitEpExOZ+r447Ix1nKVd7UIu41vG2rP7M5Zf8Ldv+y34Ny0PXfpLDzEIU6nr2npNihQ/ckLPCtp/Vb2dwKh9ZNw6MYEOEPP0AfmFvGz242VeHRYzyF4Y/odXP4QbVr3Gjv7wqJqOucAHwpiMNZT45DwMoK1x9R9EXEQzGv4qIusq+swworzxqXrSch59c9fB22D/jrwCdOiCbA6CP7+eimSsVIe/P12s4KsCk0AaFfuIkhfu5VBz5+adVL01D3lOZhSvwo7vfAMBxOOLj42RFGIswtyPXAOEqlqR+eQsZEfYkKZ1NqIdOmr09oMeFf9fguuX+OopghBPCDmEZWIfnqv4n/36xFiONdnLQ+BTF2Y9nGbtSAXWM/u4+V+7J5giShNKXoe9qIbJgjzsqDyHczpHzP3JxjuImYHRJnyn30xKL5rURc0x7yJJHTQv9Nzf7BkftETtZJLGyFJNJelu8TGpVLf8JKWikcGkV9zGBH/T5SX5Ok9LaZtfsE0PdnZNwbpoaC+5rGJf2qgiLaZaw11JNHK5C2HOYvQE50cOcOH0AYo4Gwyfubn5DmpFcCKZ0pw7+qIr2dLktlbXqZYr12BolonbAoXS/DDYuH/dlax9mfWHUI3c6M95HHwOFqwjY98iKazTpxaRK39wmS25C32szvW1AOM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(376002)(136003)(346002)(39860400002)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(6636002)(52116002)(6666004)(6512007)(26005)(41300700001)(921005)(38350700002)(478600001)(38100700002)(316002)(2616005)(1076003)(83380400001)(5660300002)(66476007)(6486002)(6506007)(66556008)(8936002)(8676002)(4326008)(66946007)(15650500001)(2906002)(7416002)(86362001)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pFYVkRzcxwGv64y343ogvM/Y6hG+FkfvzsnIAhW+XOuJ0S6xB+16wH2oKyTiNo7QZofFdRoyXOnsbWixNKaatq8qiWXny0ZGf5AvlJit4ynOxgRVAJBEylJzTSb6VsLlKgxyVMjGpBOx7T81o6LvgSqh7EcYGZAohvTPnHzu/67gHpBMO+ZVRUUJij+cTw4Vigc0cf1zPFMjJqy23uliAn45qnmOBJpWnlnXKUAimafwjF+5UbtI/nBoII1UX0D/ajgSqtN8sX9TX4FWeEHSiOpAc1AfZcUIa6xieu7U5FdiHPF1Pfgwo/qcbmMuqsLDTApLl5y9vC1ECpMUc2Megoo15wrISivLWEuNoDv9jH78fXjxSrhd64ig6TLAOXZWt+XzQBmEOn5MbFhPz8N1gwIEjRCrk9goAiBMZmLSNdbl5DTdyrtOZSsKgoskfSF6W7s5A8dNc35W5BzDSMQAKdMj/pyOOdMOq4BTQO7+5+4q9oNoCYYWyCx35sZpjEPP/D/P/2aT4WbYS2OIrSI/kMoZ31cwTBxMlbAxz1SjK0YWDbVNp6doCj7iT4ITOtY2XibT6NhXC7dfTYSUwj7MnE+efyKEOD/M2in7agRWTUYny2Sgzvs88MPx0eYfvHr+YG0xie7+k0z9FOH6hQDGR4W8ijYueiBIW231fJU6b05yi+BNcrhQF/0ZdLwD4G8moCpV800UVSDIU57mj97oiCkXKoMI6GBnu9k2s5NV5/eziV7XT5T47eFajMJTbL6WFRdjbWvxmoQUUtCbZcsOAxvkXQz1C3mWlRHefGGKS2CiNuLskKqSDruDxSxjmhknpvgPs7sZ8q6lIJKZ9ZuZW4q/mqTRtB8Kz7HCn5A44SjpvzlYMosYtJWbkUn8PvVJP1lOAx7s0EEkzT7FOo7U3SogDq4Zk4SbMqWjX2nfBM0bgEwSPqYY/HX1jOTLO5PW35GsTPkieUuQqMWLvfaejSoADw6Ciz35gk2B9+4BiSCLXDBddpOwy5dFW1SZhawkhd/Ibm/DtPVC2TGcX5ectF3vLuzLSKNCob/mdznk7kslMZ4KO0xighDirskbPVAq38tQXQA0yqsnp7Feolp0Qv3+5Px20+GOWVX7krkTTtJPmoIK2NiCSNKoMxk5p/4yrId6tF9ALKn4Wqr+fSNOiIDfKw5HbOg5LGMJFlw+i6qB9RIgPr1TYPwWiMuR5Sr7QKbN54UtbSgWJPKJHtMHoQsGD4Hf8qgMWe1FDTzjdik2MDsKk4db59a5J6/53KVBxNwHpO3k7HPBItZVuzTMdY1tyWJlu9IZddLZe2+qANAb35YazoOo3fYRd/5oBJUgOmXkO0B2JBKMLwO3aW7cYV5Dgv7iXv0R9/z8awWDMUYMLVH+ptLAMWOb3EA8/DeteaKswP0PzqqpfzpUS6XsewDm4I6n9Utfl+Z0BgBYE/ki9N3DWY0a68wRJK0ms5Ajaq7hcLWHr8YjWQ5HZ7rQaG3ev1/heLzJrIc+hOlTIk2M1/tYdCSaquC4vyDGMfyebfxZDw2PPy/Lu97xEJGHpTgFfohbl2e2m/dSedeUIKc3CO4WwA3T6fuJeMQp7dntzAqno1Yn3wSGF9LguwWOuQ== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73d56853-3f4e-46e1-4b0d-08dbbfff71e8 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 08:46:45.3147 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YN1sSSx+uxQyWon+hRas+Js142YXSU3lBBHs53DGTs+z8EX6S12Sks8CVBOjGnjntMqK/IdZQLQ5M0/EofrYsEChFzMryDmo/CAiKETw22g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8475 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Indicate next PN update using update_pn flag in macsec_context. Offloaded MACsec implementations does not know whether or not the MACSEC_SA_ATTR_PN attribute was passed for an SA update and assume that next PN should always updated, but this is not always true. Signed-off-by: Radu Pirea (NXP OSS) --- Changes in v6: - changed update_pn description Changes in v5: - none Changes in v4: - patch added in v4 drivers/net/macsec.c | 2 ++ include/net/macsec.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c index b7e151439c48..c5cd4551c67c 100644 --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -2383,6 +2383,7 @@ static int macsec_upd_txsa(struct sk_buff *skb, struct genl_info *info) ctx.sa.assoc_num = assoc_num; ctx.sa.tx_sa = tx_sa; + ctx.sa.update_pn = !!prev_pn.full64; ctx.secy = secy; ret = macsec_offload(ops->mdo_upd_txsa, &ctx); @@ -2476,6 +2477,7 @@ static int macsec_upd_rxsa(struct sk_buff *skb, struct genl_info *info) ctx.sa.assoc_num = assoc_num; ctx.sa.rx_sa = rx_sa; + ctx.sa.update_pn = !!prev_pn.full64; ctx.secy = secy; ret = macsec_offload(ops->mdo_upd_rxsa, &ctx); diff --git a/include/net/macsec.h b/include/net/macsec.h index ecae5eeb021a..0821fa5088c0 100644 --- a/include/net/macsec.h +++ b/include/net/macsec.h @@ -254,6 +254,7 @@ struct macsec_secy { * @offload: MACsec offload status * @secy: pointer to a MACsec SecY * @rx_sc: pointer to a RX SC + * @update_pn: when updating the SA, update the next PN * @assoc_num: association number of the target SA * @key: key of the target SA * @rx_sa: pointer to an RX SA if a RX SA is added/updated/removed @@ -274,6 +275,7 @@ struct macsec_context { struct macsec_secy *secy; struct macsec_rx_sc *rx_sc; struct { + bool update_pn; unsigned char assoc_num; u8 key[MACSEC_MAX_KEY_LEN]; union { From patchwork Thu Sep 28 08:44:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13402289 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5983320B31 for ; Thu, 28 Sep 2023 08:47:24 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2079.outbound.protection.outlook.com [40.107.21.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5934A1A1; Thu, 28 Sep 2023 01:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gP3dl+vEZpL0C2mG8uRTNphJiXb4OQd5dgTS5mpbkGpPE7RaWVqkQ5x8vEOkHs6wU4B15/oez0j+eqMWbXknzNkGpEp//xt8XyySTLPAeUqZvuecLxFCxp/Yhn+cknpgpJEJCjkk40ejmjSPL44DwmS0dV8iANBW1yxBEqBCBDYL0lcXlIB6mcQrpUjZ4fuEYmKg4E4ff6kaGB7FyzMZmBs0KlsrKCgXCHAbaa6Sbw94zzefSuO9SMTrNd7SrRy4X4cuWRYDIM21JYyGek2ExHcU5tfvvr3cr/sQ2Zo+TOu0wegKhZzlibPGUPG/eM2mv8K5gVtG9JaXDzAyWPy62Q== 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=OTKHGEQWyH0vwp//V+E2asoik8YKanaGHPBAdcOqHlo=; b=fKKzYgG1R5/kRLrGP8NuvA0xOxoR8k4e3j9um4iIIk6i14eJuHTS3R3sw5RqRedAoUA2IcPBCoM/3cWRPV2g/uEVt6oQnUjANLKtscEB3m4erWBGiX+qDSpHeqH3SFI5dONsXYHmbmhnm1j5lOqJI1KCa9s3yOQwlYfXQHIeerQ2Sw4waZ4h99lTOO3jtN4wOlghlEziR9lv3EFzeCE8GFyvHeLir9ol/SvImRchdUgcvlRzEQuT5/P6HyXrBs8j6nbX1Pze1vvIc7beJnLXzM/fsBY8dPr+XhSKCEro4rB1p2W6Gecro2r6WjQw9HeBetf3cTn6t5khObvKQ7G7vw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OTKHGEQWyH0vwp//V+E2asoik8YKanaGHPBAdcOqHlo=; b=P2F320hEm4fLOm5aGNPJHGLljwn7TKzlYmDaM50gCwbtR+IMRhLh7AYFgkKJdsCIt0EBkgej3ipj+wmoYJaxMGYTvdNdgB8ZSkANuJeGCdOvrdRUKTrWb6gqUpmP9HOqRwhHUoO5tcm51kF37dLEHr6ruRlBFgE4wINu/akJkpU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by PAXPR04MB8475.eurprd04.prod.outlook.com (2603:10a6:102:1de::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 08:47:16 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617%7]) with mapi id 15.20.6813.027; Thu, 28 Sep 2023 08:47:16 +0000 From: "Radu Pirea (NXP OSS)" To: sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com, hkelam@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, borisp@nvidia.com, saeedm@nvidia.com, leon@kernel.org, sd@queasysnail.net, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, richardcochran@gmail.com, sebastian.tobuschat@oss.nxp.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v6 04/10] net: macsec: introduce mdo_insert_tx_tag Date: Thu, 28 Sep 2023 11:44:24 +0300 Message-Id: <20230928084430.1882670-5-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> References: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1P190CA0018.EURP190.PROD.OUTLOOK.COM (2603:10a6:802:2b::31) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|PAXPR04MB8475:EE_ X-MS-Office365-Filtering-Correlation-Id: abb2a6bb-f20f-48c8-4673-08dbbfff7999 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yE0gxPMMEvuNYSobDLM0nxukIh8o6Kr5Nm6SHvdypeuDt8zGk6bdnU2S3wcEIpfoQBEE0y4CwijFTlioJXaRw5eda7sQF8unons/p0OimrdJ11NLdpRcYH6N3g4HfwrhzuXDKJReNFQvwSivORwjuBmNRu2+x35E7RcQmUAlaOU74cxDYQ0/kcUqp7mOJU07Ctat9Y/XdD55EvMKBquaRQp1j2ONk04bi6OeXp0hVVpQbKoNMIQzUtGIi3GxpkBpRv4kdQa3pft8RgF+faqiTgwvKLsjAyT5cxmAcgUrhHcPdeFG7YbSrm8VMQsUGSgUC79kOPRi/SeyNf+G1mg8/ZTkjhAclirOezOaDSo3WGBzrtXP7ZTW4xVl9sFHm/2QfheP/37rkXzt7TipOOpkKxShrpsgGMi3meuIYueS2deIDaW0Jxo07ry4u/xhmN8cIQe2uhE8VpNU1O8G/lKxnwBY7KX2F+93UumlB21kKqS8LQh2ChBF/L4RVtC2bXCXHjJNyvQ0CZZPTXhg9QoPKjH5kRz9a26hG3HpxLeRDx9myjwU+5/yJdQw7bjnTh0jZ02UXfTFpqp6tURzWbNWhDVDja3//zVkCaaiu/tFeuCFCh2/AERSzCj1m0gLUhQyMdCaz/qhDRGbLFNRNqfHDQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(376002)(136003)(346002)(39860400002)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(6636002)(52116002)(6666004)(6512007)(26005)(41300700001)(921005)(38350700002)(478600001)(38100700002)(316002)(2616005)(1076003)(83380400001)(5660300002)(66476007)(6486002)(6506007)(66556008)(8936002)(8676002)(4326008)(66946007)(2906002)(7416002)(66899024)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NbANHzI0J7YyMZCzVWlXQPHZ4sRUxkbcZY7Kb5IMiLseOTlO+kO0QkwaLTG34RuBte46I/GVtM8haWE8HFr9tVNYk7zFc4hItLFvkEHj7ghEuV2L9D76KF67DJiaMiIkoRym7ADXkBm1W7KgQs5t5qfhKoTKTBgr1RG4XiLGLTKQNh9BL3n7eaTf0iAwpkwhsQ2Ugbdn9IG85IIn8yN+Sw+0IGTT94cm8lUGg308Pc2okR4vL+tW2aRl5ES7Lyu5vlJqMnlVF9/qMjs8v6L+loxowhbj7Sjp5AZiVLlXXSmtV9d329dh3HzQw6Vf5XOTEXqjn3qZ3COJGQ0y3gErXkL+BrJfc/e00+M7xcrTBn82F4xlufuQWPreUh7uCsBMPKbsBTCoiwVnLeTPlBN8WAkcTlmZFe6fBhHE1omqC2XKFyydQCR4hGe6fUkkKiQ2304F64UFQxWvOTy54CUwCafH62ujsM75OJvSyx6ntIZ8hSyh5V5ML6Y3sMN6unQ4c8l3qTA01fQ6kq+BFor1Trz8jnRztH4xb+ta+YSD4ZVYs8+4vfWnSyRJh3IROeNAfk7xYF5fduxP2x5+OFkTMTUAPccrFZPMFmDIDjN8Vmq4OoDBEjhYLdvFfiFYKGwM5HmM0+SN/eZQbSHHL4dZpVatvkwNI77KxxEyEyw17NNW6Xx7SwxMo1dhH+k+rCIFSMullqYxCFsEZmtCelYEyOrFcePKgaImypTsdKRcga1l4a56SAqiIjPulOp13N+CBG674L3N7rI21bgSqErxk7uHHtBNX6C7yIn06Ffzew7PphHaUceuK0F+V1eLQ8fl7JC33UkSKPez/nbFyTGY6MGjk0w2l3iRxLAC7VKcHRWNdsLCh3yV5lLzK2nq2QvqkE3QycjZ5K9N4AU+KUPCQQ/QLxoTtD5+nidScoliCDUssCdyRECqUVzDTtO0SsFPupS84Hr1SL0RDIbrcjyhLXsnwty6DJSDI/PE6qBIADqWojwlHaODUaYpt3z+ERkBgiUwQoM8dSISZp6TGTsUVg+3dmWn5hxDK44AfKMxWQI489vS4r2+0kwe+i8b6TIGvUaU7xyFxsdp6a7HaskTWwK4y/dZmBqvWITHG89BLqA5UO7jazA67uYIZKyZ9jiZXT8YkLzdvv6KL9uzOzKvIuJRLTucHlRGamDJ9VL5WvQPEjMzk0X8NDMV7tihowTSlhdci/6+STmdgMCrgxlTNv7bJN0fLYcHHrPinmLgGEs8pIpWigfbKuQWbywxZY9n0BWGkQ1wj/BUvVij8gvPDXiTqNUddLoJQMe/XmhRMd6V2BB160LYQFtDii3BAoC9Uz6rs6/usGl9iTqUgRKWSGqMD89dMwp5+mwPHyMqPdkz6Ai7PKzcb//9nXUZuGKwebWy4R8eBwTvU4dy16KT/NHKSFKQo8RKUg83I87CHwurZwf18F4GiPgMDJ75ODxEiBvZjGoEkQ1FYNK8k+V9bL097b0XwtmoMHtroWwXQR5sYfFjMvLC67+aS0cblEO0/L+ZeGjrg5Wzl+0Dyy+onBoMxxyBKAxfyP6/bP/amZFKeyRO4VoFsSlK6B1pOYElBN6jZ9p2OmOGZBnhQxNp9g== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: abb2a6bb-f20f-48c8-4673-08dbbfff7999 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 08:46:58.2263 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2B9wF8zFqhd99A2exr+JRKm7qjy+P9amjY0309XJz/BpvyiF55djtv5rjB+E4fYhx+k2EbmJxjjJhNdiW2maW2RKnjmAhjZYugKAc+967Qw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8475 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Offloading MACsec in PHYs requires inserting the SecTAG and the ICV in the ethernet frame. This operation will increase the frame size with up to 32 bytes. If the frames are sent at line rate, the PHY will not have enough room to insert the SecTAG and the ICV. Some PHYs use a hardware buffer to store a number of ethernet frames and, if it fills up, a pause frame is sent to the MAC to control the flow. This HW implementation does not need any modification in the stack. Other PHYs might offer to use a specific ethertype with some padding bytes present in the ethernet frame. This ethertype and its associated bytes will be replaced by the SecTAG and ICV. mdo_insert_tx_tag allows the PHY drivers to add any specific tag in the skb. Signed-off-by: Radu Pirea (NXP OSS) --- Changes in v6: - none Changes in v5: - none Changes in v4: - none Changes in v3: - improved insert_tx_tag flag description - macsec_adjust_room uses the difference between MACsec room and device room to adjust the macsec netdev room. - macsec_update_offload return error instead of goto - macsec_can_insert_tx_tag renamed to macsec_needs_tx_tag - insert_tx_tag flag is checked in macsec_start_xmit - "TX offload tag" replaced with "TX tag" Changes in v2: - added new fields documentation - removed unnecesary checks in insert_tx_tag - adjusted mdo_insert_tx_tag parameters. macsec_context replaced with phy_device and sk_buff - statistiscs incremented with DEV_STATS_INC - improved patch description drivers/net/macsec.c | 92 +++++++++++++++++++++++++++++++++++++++++++- include/net/macsec.h | 10 +++++ 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c index c5cd4551c67c..f0ff33025500 100644 --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -93,6 +93,8 @@ struct pcpu_secy_stats { * @secys: linked list of SecY's on the underlying device * @gro_cells: pointer to the Generic Receive Offload cell * @offload: status of offloading on the MACsec device + * @insert_tx_tag: when offloading, device requires to insert an + * additional tag */ struct macsec_dev { struct macsec_secy secy; @@ -102,6 +104,7 @@ struct macsec_dev { struct list_head secys; struct gro_cells gro_cells; enum macsec_offload offload; + bool insert_tx_tag; }; /** @@ -2583,6 +2586,29 @@ static bool macsec_is_configured(struct macsec_dev *macsec) return false; } +static bool macsec_needs_tx_tag(struct macsec_dev *macsec, + const struct macsec_ops *ops) +{ + return macsec->offload == MACSEC_OFFLOAD_PHY && + ops->mdo_insert_tx_tag; +} + +static void macsec_adjust_room(struct net_device *dev, + const struct macsec_ops *ops) +{ + int diff_headroom = MACSEC_NEEDED_HEADROOM - ops->needed_headroom; + int diff_tailroom = MACSEC_NEEDED_TAILROOM - ops->needed_tailroom; + struct macsec_dev *macsec = macsec_priv(dev); + + if (macsec_is_offloaded(macsec)) { + dev->needed_headroom -= diff_headroom; + dev->needed_tailroom -= diff_tailroom; + } else { + dev->needed_headroom += diff_headroom; + dev->needed_tailroom += diff_tailroom; + } +} + static int macsec_update_offload(struct net_device *dev, enum macsec_offload offload) { enum macsec_offload prev_offload; @@ -2620,8 +2646,13 @@ static int macsec_update_offload(struct net_device *dev, enum macsec_offload off ctx.secy = &macsec->secy; ret = offload == MACSEC_OFFLOAD_OFF ? macsec_offload(ops->mdo_del_secy, &ctx) : macsec_offload(ops->mdo_add_secy, &ctx); - if (ret) + if (ret) { macsec->offload = prev_offload; + return ret; + } + + macsec_adjust_room(dev, ops); + macsec->insert_tx_tag = macsec_needs_tx_tag(macsec, ops); return ret; } @@ -3379,6 +3410,52 @@ static struct genl_family macsec_fam __ro_after_init = { .resv_start_op = MACSEC_CMD_UPD_OFFLOAD + 1, }; +static struct sk_buff *macsec_insert_tx_tag(struct sk_buff *skb, + struct net_device *dev) +{ + struct macsec_dev *macsec = macsec_priv(dev); + const struct macsec_ops *ops; + struct phy_device *phydev; + struct macsec_context ctx; + int err; + + ops = macsec_get_ops(macsec, &ctx); + phydev = macsec->real_dev->phydev; + + if (unlikely(skb_headroom(skb) < ops->needed_headroom || + skb_tailroom(skb) < ops->needed_tailroom)) { + struct sk_buff *nskb = skb_copy_expand(skb, + ops->needed_headroom, + ops->needed_tailroom, + GFP_ATOMIC); + if (likely(nskb)) { + consume_skb(skb); + skb = nskb; + } else { + err = -ENOMEM; + goto cleanup; + } + } else { + skb = skb_unshare(skb, GFP_ATOMIC); + if (!skb) + return ERR_PTR(-ENOMEM); + } + + err = ops->mdo_insert_tx_tag(phydev, skb); + if (unlikely(err)) + goto cleanup; + + if (unlikely(skb->len - ETH_HLEN > macsec_priv(dev)->real_dev->mtu)) { + err = -EINVAL; + goto cleanup; + } + + return skb; +cleanup: + kfree_skb(skb); + return ERR_PTR(err); +} + static netdev_tx_t macsec_start_xmit(struct sk_buff *skb, struct net_device *dev) { @@ -3393,6 +3470,15 @@ static netdev_tx_t macsec_start_xmit(struct sk_buff *skb, skb_dst_drop(skb); dst_hold(&md_dst->dst); skb_dst_set(skb, &md_dst->dst); + + if (macsec->insert_tx_tag) { + skb = macsec_insert_tx_tag(skb, dev); + if (IS_ERR(skb)) { + DEV_STATS_INC(dev, tx_dropped); + return NETDEV_TX_OK; + } + } + skb->dev = macsec->real_dev; return dev_queue_xmit(skb); } @@ -4126,6 +4212,10 @@ static int macsec_newlink(struct net *net, struct net_device *dev, err = macsec_offload(ops->mdo_add_secy, &ctx); if (err) goto del_dev; + + macsec_adjust_room(dev, ops); + macsec->insert_tx_tag = + macsec_needs_tx_tag(macsec, ops); } } diff --git a/include/net/macsec.h b/include/net/macsec.h index 0821fa5088c0..dbd22180cc5c 100644 --- a/include/net/macsec.h +++ b/include/net/macsec.h @@ -316,6 +316,11 @@ struct macsec_context { * @mdo_get_tx_sa_stats: called when TX SA stats are read * @mdo_get_rx_sc_stats: called when RX SC stats are read * @mdo_get_rx_sa_stats: called when RX SA stats are read + * @mdo_insert_tx_tag: called to insert the TX tag + * @needed_headroom: number of bytes reserved at the beginning of the sk_buff + * for the TX tag + * @needed_tailroom: number of bytes reserved at the end of the sk_buff for the + * TX tag */ struct macsec_ops { /* Device wide */ @@ -342,6 +347,11 @@ struct macsec_ops { int (*mdo_get_tx_sa_stats)(struct macsec_context *ctx); int (*mdo_get_rx_sc_stats)(struct macsec_context *ctx); int (*mdo_get_rx_sa_stats)(struct macsec_context *ctx); + /* Offload tag */ + int (*mdo_insert_tx_tag)(struct phy_device *phydev, + struct sk_buff *skb); + unsigned int needed_headroom; + unsigned int needed_tailroom; }; void macsec_pn_wrapped(struct macsec_secy *secy, struct macsec_tx_sa *tx_sa); From patchwork Thu Sep 28 08:44:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13402290 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07BEB20B04 for ; Thu, 28 Sep 2023 08:47:49 +0000 (UTC) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2052.outbound.protection.outlook.com [40.107.14.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1C3C9C; Thu, 28 Sep 2023 01:47:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XVEyJ+qXQYTdfs29Brgp+b0V/1k6mfqbIvsHOs5BBjduI8RSyTB55uQsgEVCgHtcH9yPZ8wSQQ0tRSpb4pQrtRxhPXZp2rv5YRMQ+I27pZBuVMLrKbE6HIaij1FU7L2UAGSYUJIy+1pig6GCFdsr6ZTNnMO4fKs1bcj96ydcbRJ3HFvUIofvUsdGpeQ/SSD09F3ZgCggucKoiUOiDzDB5IulUfZWpSH6IKZQarqYvY/+I9UiNa4I4Gko57nSOEMyo1SLjb7sSumKnW5220HLR5qqnx3YSLe0r6NC3ah6jY9dhIXZJlwVlK5Jm8NBrCEjDcwZsT535Rf9DLjl5r103A== 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=YOaGR7AwYpP42vjC209vORt773LJsJ1Prod6yInbC/A=; b=I7qCuDvZg9Hkn/C+RAInYDZKtxJyASiDIG86eICHmb1wFXmB9ixNnVA0nGgYgTdZYPTJMSy9r1iC9rCQzlPb0OiMuPGmbXNbI+6i8kOGHpD944NiF6kp2JA2p0C0dN34mbcjILMmOFY6mV0TVte22MgaQs+TKQdYMnfrer5vG1lQGeeh2HOKuJJoc+J6++3IwuvPg2vkCigv3gUbN4aN4t7D8A7NcJDtmU4HFCPGEoZTYtNHWY65I2EK3h8o25QAnioSjG9M6o+X4fzn050FU3ptcajAVyjrmDOVvvZxZJc686feYTt4XlJLeof+woNbWnn1gGBA6ZkRjo+M3trbkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YOaGR7AwYpP42vjC209vORt773LJsJ1Prod6yInbC/A=; b=iMeg3a5WJwe2z6Y70fdqhIJWY3BqcTS4uw8CAVEnQ6R5lO9Oe6auboRoek3yN4u/If6DGwn9C770YkBcOath7RcVDplxe7eqV2Ka9zcT4SEPuXuSb8l83mSwBv1ddkrgxlbiUHmfF6xlvOUDRZr32AG0+h3R+jwUrz0/3cDNv0k= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AS8PR04MB8514.eurprd04.prod.outlook.com (2603:10a6:20b:341::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 08:47:43 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617%7]) with mapi id 15.20.6813.027; Thu, 28 Sep 2023 08:47:43 +0000 From: "Radu Pirea (NXP OSS)" To: sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com, hkelam@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, borisp@nvidia.com, saeedm@nvidia.com, leon@kernel.org, sd@queasysnail.net, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, richardcochran@gmail.com, sebastian.tobuschat@oss.nxp.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v6 05/10] octeontx2-pf: mcs: update PN only when update_pn is true Date: Thu, 28 Sep 2023 11:44:25 +0300 Message-Id: <20230928084430.1882670-6-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> References: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1P190CA0018.EURP190.PROD.OUTLOOK.COM (2603:10a6:802:2b::31) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AS8PR04MB8514:EE_ X-MS-Office365-Filtering-Correlation-Id: 6447dde5-a622-4139-06c8-08dbbfff84a2 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bqSimji4B/iMcKeVA7XTNRDnkURUBtX50cxDQ8McliZbw+5rY5omF1F86gV0U30eIc0C7XkJKTAqBqCS+LTdJBM3wuluHYYNVmhXAlMTjQrbKVaFjt0xcxs4eGrxBO+aMyHtScpwwJGjmazLX1sf+Sj/3XZejw3PZBviNTtnwebznzctmWMIPPQsVzxMxSAVQIjdWMCrnPhxE63kUWRnR+tQl0iarbJHIWwPgZTH+NySntBv33BiHbbs5p2XxnB05LltrGbKHUlaEQ0B2zt9Wpa47qv/ewVaRF5iPtXlmhVv6a5J1CKuTBxrzafpg+KJ9nDzArWhXCAYteGWRRGWZxDyZFgmJAn1/0Nv9dJnWY2wV7vDY5eCzQ/to+NlyUSNscG4fLv4BWw+Qzwuou6Zm6UDs+YlBfi8fQeEr/VvYjIuPgkwpKf26eKjvt5SMV8qd1oOUhfIexbmYzXqTsCEojOiCVYnQd84T+IrbYyh9XtDUGfl3kMxZoECb5TdJOBPuJ1DDT6aXd9/dlvkM0bo1mGidvWS4DJIxrxgN1L6LuyMyyOMFnrFEWj1tizqIa40cSJoVrDs6BKh4ybG6T9jmasUgKhOhtIdgahxv5Lz/ofjNsaAatu3WnC7Aqd1OuDl X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(366004)(396003)(346002)(376002)(39860400002)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(6506007)(26005)(66476007)(66556008)(6666004)(86362001)(52116002)(1076003)(6512007)(6486002)(478600001)(2906002)(38350700002)(38100700002)(83380400001)(7416002)(316002)(8936002)(5660300002)(4326008)(2616005)(66946007)(8676002)(15650500001)(921005)(6636002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sxy94rFrcUXvjLjsSAcT8D9WEnHlUY7iJhOV2A1LowvxGMNmp2hwovz2aw+1ygwSbsWyIpgQPmo91OTVYsWhGyOf2K7pFaYxKHdKehXzF7MgLWuAHUUV3epoXpZ/l+AYoNXaiER7HZAs4grYI8d7L1Zc1rJrGIsBJcJKWg0pbY8NNsHjcTwnmtQDtLiRbmd9JD7/F1g+j1VXlhM43sXx/qsxF8Op0Ljomx1uhXQyZc/+VVd5x+c4j1QRyYQou3yX2UW0SNfk2WbhNgHZiWZcknjo4gh/Wfq25hCCzITBat1jXF7AykBXTV8raNE0DufhoXGxMFeWhulTlIonjEIYY9HbdtIM0XtH0TwZlE4rGrC1vFF09tbwEX/ig8GSJmZNOqdMWPGSJWtvFZYJv3EqwLvexVtrbSJO24OCYyx0ip449QEs5p8cGOdfoq+2gKlKI4wvUhz2NtQiVqJNbHjdNUwEFhzLaPuzhMy1H0BnLvicQOTq/r37T9Y8NvKwKooATFfcvSeAl+LIDXLA+YdiYbwKKAjcGPwSqcbRTYSlybKZDkQ9wMWBHvx2ddx48BaJRmhmsYfGIPBx9J6/jSn7SCM5h+4Sk4TT93phgZuNPGgk2PAt838a7ljqm4J1ozGp89TjxnbmzNTgauLFZCrqOIWEZf3AVta304P5/2kgn8xb0AshAcYM2T+AhYSVendBm4Uimjk0FyCs3D0MrhEGR1EYPrwN2vaFIU2wd+d21WV9DGXmUOc8DV2wfbRoj8XpFXkBXtuuUziaSSUZQML2Giz6YgDgwaBVzy1763aVHb5yOu85NsJxR1XDjd11cOVaz8CiJ7v+EuNQYxdY4MdMsnmkkCnPNLIG1jOuhpYv2HITmXePzoYVH13ZnXvOxDUgrZyfKDhh+pwWw8lqnpRWQEBKhnz6/Y4Q+Za0J25vYDk7Ap72fBYTlg4AkhJKQUm2gqHkdZFz2E1v3K5XGs+gu344BSov20vzgf7pabBQXb8Do/xCbodBZDUNxAKbFHso5JhA4bLLpr1aMBYDbCiXaESCwgV+kGqy2pq8wu1PRQqNVD6hn3O3G7X6dApShj5ATlOZhDeu/KtWu2xnrNIUqVJJeFTxl9Z1lL9T4dXVvyKFYrCt+v95Z3+h05NxQqhqkrNZr5Hb4bWjgNOrZjbhanc3n3rphVVRrLy/mInT2KW6f0kQOXxaS7glfzVgdwjJAhumn13qM7KeNSwaNUO4Wkyf3rzMI8MVILy/1e6bt+7Z/nD2yUVO1gUkvJmyepuWR2otj8ojUSjFDS1JsmcGXz16q6kuPc4x47vxSehO0ft6U58yvlBe4zHtt3db6O8vpU3sC94Gc1Aw496bvcNdi0AbhL/24npo5xN7oaEOdhPZUNYjJ91b6ZwTuL5dKxVTCQNJNDeafSrxAzA8IDG4xpaABrk7TlahLIMafo3lTuDK00pL7esW53FZf7LOiGnA1KaYlUA43ptHocw/Os4hNL93ndRN5NGvkEoAMjyIZU935LtAJ9/LlmxahdY5GWRCRsv1CnRv7FN0FzfRapShS/CP7/rSLk7UvU1olaiZJP/ZehiwRqhIiFTc68gburp/INmV50spw4YDw0jXlK3n2A== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6447dde5-a622-4139-06c8-08dbbfff84a2 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 08:47:16.7396 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Bw8lczhdXJ495Y33Uzrx1WIevVh17/CF5iB8vKnNNgLAU1rfKVUCQqTquzMZLsSD8OYXOFpB+aLt85gOFlyiVpiZxc+an9o17hneMiuyjbU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8514 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org When updating SA, update the PN only when the update_pn flag is true. Otherwise, the PN will be reset to its previous value. Signed-off-by: Radu Pirea (NXP OSS) --- Changes in v6: - patch added in v6 drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c b/drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c index 59b138214af2..4c59850dfddf 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c @@ -1362,6 +1362,9 @@ static int cn10k_mdo_upd_txsa(struct macsec_context *ctx) if (err) return err; + if (!ctx->sa.update_pn) + return 0; + err = cn10k_mcs_link_tx_sa2sc(pfvf, secy, txsc, sa_num, sw_tx_sa->active); if (err) @@ -1529,6 +1532,9 @@ static int cn10k_mdo_upd_rxsa(struct macsec_context *ctx) if (err) return err; + if (!ctx->sa.update_pn) + return 0; + err = cn10k_mcs_write_rx_sa_pn(pfvf, rxsc, sa_num, rx_sa->next_pn); if (err) From patchwork Thu Sep 28 08:44:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13402291 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A76B028DCC for ; Thu, 28 Sep 2023 08:47:55 +0000 (UTC) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2084.outbound.protection.outlook.com [40.107.6.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5124F1AA; Thu, 28 Sep 2023 01:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VxGx+7u6Qomxp+Oo1XTVX9cuMoal4WqsbhcPBqgKTs9IT/qk1yKFovGC63W9aXuG9IrRh53u4cyf61MucC9gIZRrnS4EipDdcNYRPU9aKUQbohYLuUHa/kzInFy2g55xs5XKP4EQx4qavpXaFU+YNYm3rCXaC0pZcQ/BkYhJwaN9NsekuSYPHqiT+4rw9u82q/Cte4GVBRApNAANRmuF7CIgYGaUnHn3GIthWxnQyzhx/xrjLdoXqgVnsZnN6ZGicY8fw10XRle9v/xrbryaYLj6AA3Ta0A2HdNToZUP9MppH+eIubnpBjDv/g/SS8orx3p/XWbD2Na1SG9WdX1TGg== 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=8YD8gARdxhUZn7u18VU7g4skk17BOPVisbnpfYNFdqs=; b=OMdIVvMoNq5+1qaOM94xTgSZk9GGGWGPbjiXbLaAJMkzkgbX6z9Qk+K/Voq+tFM2QE4EhjLXhMIYlwZ/lZGRXF7uoOAxvYsT+Y/+wxSEITId7K5Mz3HK4/ZQOpci3zxwc9yeUqHW3T2743rd7eRoTBdIVqLvS0JY1i9g/D07tyWeaoROELn1dNZDS4yq/BTDP4Wm4DJkbGzN9MiZKRTacIhfyzxTbv0Ux1Gyl7Z4Tlz3AjdIpFQ4NfMmUqQ5u8zEhgM67aGy3WFgkfvbm/qyquLNIbnILpmfixiL6Nm0GaqP53WaKgTCsCSJwVq2ptsNNRYd3NeW+S9x+pZhvi+Oxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8YD8gARdxhUZn7u18VU7g4skk17BOPVisbnpfYNFdqs=; b=AhqPyuMsotQ7/JxkbtywU/NDZ+tUTI1sD2GL8JoOL0+Vgq9PrtzF2G/5f4q/9E6m4h/jw+7AWyp70dAjYEioNe65ZI8vaS/vgvw+hxrPvGQo7YYnZLfgDXYqt355W4iaDT+BUfCWM2k21kerAbwyY/xz0DF5bMKQdhsmqVwa7UQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AM7PR04MB7031.eurprd04.prod.outlook.com (2603:10a6:20b:116::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 08:47:50 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617%7]) with mapi id 15.20.6813.027; Thu, 28 Sep 2023 08:47:50 +0000 From: "Radu Pirea (NXP OSS)" To: sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com, hkelam@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, borisp@nvidia.com, saeedm@nvidia.com, leon@kernel.org, sd@queasysnail.net, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, richardcochran@gmail.com, sebastian.tobuschat@oss.nxp.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v6 06/10] net: phy: mscc: macsec: reject PN update requests Date: Thu, 28 Sep 2023 11:44:26 +0300 Message-Id: <20230928084430.1882670-7-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> References: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1P190CA0018.EURP190.PROD.OUTLOOK.COM (2603:10a6:802:2b::31) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AM7PR04MB7031:EE_ X-MS-Office365-Filtering-Correlation-Id: 5707440c-700c-48b7-1634-08dbbfff8ecd X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D+p+hc/q20wtjMcxMHPEmdL/mV0YnonmcyvqXhfGlnUW4X4HGTckUG2+CY70PzKKifFTiTbXr9fFNPZn6GUgdQpZxAPSEyR4TEVzBex927N/6aB8QesXk0EYJp2qp6Pj30HDpnNk0++rgaBdL8sdgqoroJ7RooREVxyCtKYlwuF4xAmWXk4VqNOY3z5ms4F9XoDvEpyHMKIrgpqZ+IFagoqO8NHsxXLKjCjfMdA/aW8kPhQz3KWc1qrlwjQBpIeAI3jmXZBrX3YlJxYaIy2W5j1LT3UU89SxnSY2DMybhMob7k/NvJUoeXwJBP/KKtj4t3JuYSY+iRppoonwk/Kmw1AP+qd7NbeGdkqyqkxJ+GTJospDtIj8FLsjDTlmX3qVgVOYM73879ynmddsDEj5sxDnN55wk1vLW5Mm3Lsfc/9puNr0uB3Mf2c6751jIWN63dunjRS3LV1+Mg+DJqIvdDW+251HGkfhExUC084HW4w1ZyjgSjDYyoiP3+CEeoAgRcgIYschOL+FDGB7iVsgMYuRxOAMUDni2Xl4uB+poO50zVJz72/Eue//LBF7zjnmM6Dq/w38Br7sR32chtSzRYZb7vc5CUY3EQPh/R0E3UzqkIhVe0pphZpBxpZ1qfVL9KMvLq0MFOpbD4NByI/iiA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(376002)(396003)(39860400002)(366004)(230922051799003)(64100799003)(1800799009)(186009)(451199024)(2906002)(86362001)(4744005)(38350700002)(38100700002)(5660300002)(6512007)(6506007)(52116002)(6666004)(83380400001)(921005)(6486002)(478600001)(4326008)(8936002)(2616005)(41300700001)(7416002)(1076003)(8676002)(26005)(66476007)(66946007)(15650500001)(316002)(6636002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: T4Pw+9LuJejgKYybNFGO/fQAHPc93Vuo3e4UnbuMPsmJhcEDBIyMhZGvzVuGMGfeIV+PwkZKxCC+AjJEAzkTTTeaANQsNsSm5tt5A9fWbYULCLt2iSvB2o+rIHN167BPis5gR3QOVPS9a61anC81u6flxg7Th8Cg4KnfmBo9HSEP5mbwtcCjLWQMjJUx8YEcNFCDXyhrOu+PUQ3PUs17IEsERu+crqmtikvSrF7jZh0o5j02Z7T/NBCb/Z2pHJFV4ogy72TbV2DWNMKDahfUj+/kX+glVr4vH15n0/mqiGbDSkfcbmMCmCyTMktrz6rr15LsVGLiu0kJAxiD+vfFVUOQfuHJWBWyBkByocbkzNz4FdQf7pdPuu2XjBEnduhoSHuf/8Rd5KPGBWlf4KvDcK/bqpdI2GMmkn4ZK9W9gYXKmfSfPAZ7t0SPFHOpiCxiQQgXiB6kkY/ddxbIucer8a6qMr/recITIsdUocTCfw/lRXWhryZfU1mCo5YmN7yLZV5mtSjsFyjwttCV66WGLymE/xpShswedvGo6wbaZle5vXuAzKuIqBeMOXUDnlIWsf4had+JTL/mVhYss4Pxu5V4+1NjZZtUVeHMj2MTrOWqqQgKhTDaatS2xLDvEQt/YYIOXv1gCZasgRA4XyDeRoV0BogIOQaxCXVPWhfiefrC0c5kaFVXpt9BEq3Z7opgpa0akISdjjiyf3sPFX/4NqwqSDRlHYXpMz+K4A8/s4qiZNRunl66VCwEu0rl3IAtIbdf6HUkcpbzMmCzhjA2vagDtDRhWdWqZQOxf6NX2ULi91S1a/8FPzA1HFCrJ7+cGTBBDWDj5DPNBiT+ChTkjKKX55dVkd1Z9KS74U/ZFm7Sgvu8HJI0p0jWvUzy1gXZ+886K5ajYzhhwCUTX/WJ9m2CmehKWVSWzEcRoQ4Mb+i2N6oXlHAN8Sim9UNB+5yXz40WbFw6jIb/hQ6JfAguNO+C0hllGDe7Xdeekb6LaQI5DbePRH7BEJvBSowgL+cphJNwZGqJUdlnGH+SBmaQLeDonf9E6hEUnSH5HkRnuDeaAODPvbcqNRBTl40uYdcYHbXqgKiw7hTx+mYx/ux5736IdKn5dEz61YHmd/0tuTctP2MiBrflNdTt8q3Eo3iBjgLQ67thpODEwG5KnP1yjU8en8uiz2L6BbeZyetautd36fQcfH8p1oy3Xd+GW5tliGBNGPrvCC/+pUu4SWn/Wo61xAWzoFyuRnaEpQdGf2vaKgnoDHmRhTpwGs9GH7z9E09IYSt79nhJToazWTTY99lMLvY+H+Qwc9gNruqY+gLxxn7IEz2AjTu0wS/mliy1vSy9O67qM+Uv0E91VOxshiYpdPEym3EfrjGkw+GFKKNj+Uk+5+cupds3wItG95yvbvpIHNzb0ATo4YQ0kqMfIaGqR6TYJKxLWt81w7fnk6O5kE7eAA+uxTkMcrDIP+69vBWw3xNDmKBe5etLLK1QcoMYoXtgBGBuN2prvCxNLG+a6CTI7bKk5HpdWRBWqccuFUJcOYT+JWR0tlNY44gDWxmqQzKkGjKeYG9b2t3F4W/bEltUZ9mJbnv+2QHLtdGMSgF0mh/diiC2tVkRx3N3xw== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5707440c-700c-48b7-1634-08dbbfff8ecd X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 08:47:33.8057 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5F/DXi6zZ7RvpHn2JrxpdUiIa3VF2IXOIZwiFd9rjNto+Z+fbhGcMiyjNtxi3O3OgGRvqYQaOBt0mWEKg9j8AjhLFh/923zf4Ue/8VM2FWs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7031 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Updating the PN is not supported. Return -EINVAL if update_pn is true. Signed-off-by: Radu Pirea (NXP OSS) --- Changes in v6: - patch added in v6 drivers/net/phy/mscc/mscc_macsec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/phy/mscc/mscc_macsec.c b/drivers/net/phy/mscc/mscc_macsec.c index 018253a573b8..4f39ba63a9a9 100644 --- a/drivers/net/phy/mscc/mscc_macsec.c +++ b/drivers/net/phy/mscc/mscc_macsec.c @@ -849,6 +849,9 @@ static int vsc8584_macsec_upd_rxsa(struct macsec_context *ctx) struct macsec_flow *flow; int ret; + if (ctx->sa.update_pn) + return -EINVAL; + flow = vsc8584_macsec_find_flow(ctx, MACSEC_INGR); if (IS_ERR(flow)) return PTR_ERR(flow); @@ -900,6 +903,9 @@ static int vsc8584_macsec_upd_txsa(struct macsec_context *ctx) struct macsec_flow *flow; int ret; + if (ctx->sa.update_pn) + return -EINVAL; + flow = vsc8584_macsec_find_flow(ctx, MACSEC_EGR); if (IS_ERR(flow)) return PTR_ERR(flow); From patchwork Thu Sep 28 08:44:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13402292 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7255262A3 for ; Thu, 28 Sep 2023 08:48:21 +0000 (UTC) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2075.outbound.protection.outlook.com [40.107.6.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B99361B2; Thu, 28 Sep 2023 01:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LcB38tmDopXc/acHiKenNyCrPRUU35I/SWlz1d1p+AEhHDSIQ3ox5f4hJFNeF4spKOKP6K34bDbps1K5wuF11rYzlIKB9anSjW18VkXB5UlJlstALkqq8TjVEq5iex2xFZpbQvd4MrvM+WWe9WejrFOW5cpRRrjsf9jun2JxVzWG30NVsFOVC2goQjterTkg4m2kQTGXF9IjkayRWnW9B73SPv4r9Suz3hKQ70ODHCVrnbbbMLB7jllSxJN4LeYsnxmxmUGLJTgeSl33BzahTb2Blk5Pks7LiR85k8crHNPNSsX8tRFjCslC2JSERCwE/z6goPOVLNHzNAfNyBGcuQ== 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=6A6gygkYydHoomJeXPSTUHPEz0ndPivGEoqdBqN56mI=; b=I4Mhh/C1RuGuT7m2xIcwOLhmLop9/5o8oSAEteCjl08g26wENgn5uthWdfDkBrLHdMdm01U+adWHbTW2QKU3vH5NEbWc8pcHEm0W16jXQ/+FRD9bdMzchZQSrdVI1o2vpTnAICz4Ti4JYPZu+lp1Sb939jk3I8xIlhC6EK6YGcY3zMQvlvVJCzpoK+QdX05CBurjjJxIruz49lt8qCS6l3gtyVHXRvrFzD4ZBMFDgXxijgn5lX7Z4N8Y9PSGwUgW5dpTpvED+E4uCTC0r4kKdUQnZrAzRp202wzC3hvX5jlYRPod20NzzDneHaNsIiN3MVxAA1iL39d8RM57EywUvw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6A6gygkYydHoomJeXPSTUHPEz0ndPivGEoqdBqN56mI=; b=Iq/QPALPM3mHKB7ADX7kNpoEb5M8w0T+g8glUlsEPhALgyfc3FnxsP0zJtlCHfQM6iSGqaie9Rq1k4lcwV9G5KY+raNvsBL+KTccaMcVibYGNnBNo4Sue2Cc0cDdY3H2KEv/2koC/oOLurc9w6Pvknq/PbRAx1MHa8oiA4g7u9w= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AM7PR04MB7031.eurprd04.prod.outlook.com (2603:10a6:20b:116::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 08:48:15 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617%7]) with mapi id 15.20.6813.027; Thu, 28 Sep 2023 08:48:15 +0000 From: "Radu Pirea (NXP OSS)" To: sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com, hkelam@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, borisp@nvidia.com, saeedm@nvidia.com, leon@kernel.org, sd@queasysnail.net, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, richardcochran@gmail.com, sebastian.tobuschat@oss.nxp.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v6 07/10] net/mlx5e: macsec: use update_pn flag instead of PN comparation Date: Thu, 28 Sep 2023 11:44:27 +0300 Message-Id: <20230928084430.1882670-8-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> References: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1P190CA0018.EURP190.PROD.OUTLOOK.COM (2603:10a6:802:2b::31) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AM7PR04MB7031:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f4beede-92d6-4608-824c-08dbbfff9938 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KZfBa3iYrLROKlwBQJLseOcwkuvKpMLMuwWmybAH+lUkfvdXSz4Z0kcDv/sq44YtV9FF0NUgGEhGhxntRvYJPTbioyEBv8A9/Zv29Hex29PMU/2W06f4B49iHH3oTRIyGPeZA6qZi2UDrn4GAmiWYQcAPXQoz7fV5OxJSC4wuGSGCxdSBdqq3NtuHKuN8MTfBiOqgOMwsNC7oHKsJJdovUR/Q7eI+aDZ5u3awdd0XkQeK4kYAfA/uTBhAhEy/xbEZL22xdgZApDC4Qi5DrGYnpQssljFRcgHl5npgFiwS+eWtw8SwO8sHrtmoaWkE8mmr1vID2EwswEIKTzKgnAisd8eboQDUi+jTV4A554MjyE6RdKzY/ordbcYzixN3HfsLGsvvR+DfzZ2sp/pY4B45RcpEvrqnqd3drUeJqmuVSP+HX3V/u0mP0jCAV0jXdiDWH4Wa9yWdt0hYtGZBZN2wrdAFXhUrkP1x++D6RRdyEqWP1BmKDuUYWjrJVIRICkwl8GeptsdVFPOkkhA+8Su665V5rcDn3RSi/q1TqirB4lTQM1ABJnElVKZookBaW4BXAuy/UN08yLHhL3KUgkSFe3ITUSSzsFXDbM//muPalWUOSTYQewSt+QKWPDaeqJBmYZBsQk9KDRIymsY5BCRXQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(376002)(396003)(39860400002)(366004)(230922051799003)(64100799003)(1800799009)(186009)(451199024)(2906002)(86362001)(38350700002)(38100700002)(5660300002)(6512007)(6506007)(52116002)(6666004)(83380400001)(921005)(6486002)(478600001)(4326008)(8936002)(2616005)(41300700001)(7416002)(1076003)(8676002)(26005)(66476007)(66946007)(15650500001)(316002)(6636002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PGFUKI8Lk5BG3H3ZjRYV5V05HIfX7KC0Yo/ZEkPK7FSRqnvjDSB5J3brQNfJS/0KCPqgL9eLPlLoC4D4xnChpq07UsPu3H6LIKRng0CXRCY6tC1blMxW4w0w7Aw/di7/Gy1NJzZxQg1aejqmbeM+7PnD26/UHejWxvHxWVrVlLZVRtxflGPQTeFYZyGenpQgcLIVM6pp2cYDbUpUP3HDE+xlLQmETKoKufNahTD/EzoT0/gJbXZ29ppwUpI1I+8pNp1lv+FPXp74U2JG4DPENix2vPMI6014ohm5969GulvdeE8myuYGsDWrR2GRyaNrEyWkdTNnLrTXLskZZwDwCpWFzlh8uQ/LrZvCi8XfN+H9bcxlpWOxU5Ghm1bofew+qt4tjeUgy2AgnkrYaxSzwFX38OHlotOY0MJBY40DNeAi7fvcLoXO7S2sGTWziQU1JYGKel1fJNtcgvKY8P3Nen7lTF05vOtT4EYzn0yfUYfsSZTCKab+aDWDS9CuL1EH3I5PKAbVCotGJyG9ZWMgAv8dQ4GJh7WhWfgFfNjeMo9NdeZEFceEU6nDzGTdk0NkIuk/Ki3fDS9R8Gy59nmTIYqC3c8oQn5jHGMa7z1Zkci9huab/rRZlCUtg5FoYHZZtwEiRJq0/9037rMJv7042TDfQaA1tkBFi3wnwfmKj7LdxRrZ7GSzQhSAimUw0O+cUtyzIbIOnilZ9iTbWAbwlRg2jPHdgriNoM2zB49YoOKbzHmqcsFccsma01xeJrV7vgvUvEtcSWm/ptAFbEXMlWYDuoBPchLSMjpfy/Rnfzf9BKnj5VenCejudHt9Ae3mUW0MvcOStnn/ceODO9dq/YoqRiaHnDJI+Lv/m6D49mcVVqsoC7MydE6MZwNM6eT/pdIkP44lbu1UX0cy2AmHAKMWIYcUtrTpNyH2v+ibykYy63bOCvrjI0B+zENUqpckVemxCg6yMH8Fg2FELNv9OYE5tLrTvbR5uzSU+CHsQLJd+pb2HnRBFOe9m+czjdjvme8rk9glNbsFcj6GpXKpBsgrIepk7ZR9ef7pGu5QMlII2g8X2AkqnPpIvZZRRsxZiJM5irJwZa3V+4a5K++4yZKtnsxf+Y7vuF4jOJO35cqXoNwD6m4NtfTQiUjpp0u/Np0ygvVVoOHrToVrmrx4z/xrcdOE4xkgOL4kctm5Ts1LaayY2FMx9l5sSYcbtPq+DgZc/5jrWy+ip1CEjPEZT9tkC/QSqSf6ZTUKbQulZOU5F6xR1UNjg8Fj0L8x5ph4vbZzuVE4Um2zWL3k96fpi+WT7ij3TWz2yXs+P/UNLyv4mHbY7H01eCl8yHrlfgH856hdKaAo+J76eLxD7U0ATSxskpiBAzzmy6dXyAMQWDLtjpe/PyP9fdspUoo6T4i3N+4DjyaN2HGC0LIXLFTZzya1M9P4Q7lJ22rcjttBAkUV7D3J0mj4594WnO0BA+Vh876rqPIez0yUi8bWBG38r/uyeIv41MU++8xcVmaeU+lg0J+/C74Q9jJtUWq9EEjWmGtYJI79zKtBywiol0gTbeL1esdIC3o5Z6U5sKqSEheKnOsEpySK3ycGpjxF/8uybZDv7wWP/JJm/1yREDxuuQ== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f4beede-92d6-4608-824c-08dbbfff9938 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 08:47:52.3019 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sBWtMf+xSJDIfh2jvxQcqEEkBJYEz1ZRPY2BvF72/oDjmZuTmX58mHcLFTXsrlSCugSETGus1lFggIS1UkWZDPXg9w/Vv2LpYatjZ5pJAb0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7031 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org When updating the SA, use the new update_pn flags instead of comparing the new PN with the initial one. Signed-off-by: Radu Pirea (NXP OSS) --- Changes in v6: - patch added in v6 drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c index c9c1db971652..d4ebd8743114 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c @@ -580,7 +580,7 @@ static int mlx5e_macsec_upd_txsa(struct macsec_context *ctx) goto out; } - if (tx_sa->next_pn != ctx_tx_sa->next_pn_halves.lower) { + if (ctx->sa.update_pn) { netdev_err(netdev, "MACsec offload: update TX sa %d PN isn't supported\n", assoc_num); err = -EINVAL; @@ -973,7 +973,7 @@ static int mlx5e_macsec_upd_rxsa(struct macsec_context *ctx) goto out; } - if (rx_sa->next_pn != ctx_rx_sa->next_pn_halves.lower) { + if (ctx->sa.update_pn) { netdev_err(ctx->netdev, "MACsec offload update RX sa %d PN isn't supported\n", assoc_num); From patchwork Thu Sep 28 08:44:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13402293 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3639420B04 for ; Thu, 28 Sep 2023 08:48:51 +0000 (UTC) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2058.outbound.protection.outlook.com [40.107.22.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51B96CCD; Thu, 28 Sep 2023 01:48:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WOYCU+LeU2MFcDitN8PeYOd+jOh2t2fnbnchVOlbzvVlfi3R1eAdNMrANHGhHrIVEsi+zDQERPhk/z642vk7RPhHV6mP7s0EVFEYiCwNvZ90dJz3yXwqR6mc1M4wFWdq5T9TYPegD3MViDOzA3Ukp2mYnqvdSrdhPN08modMN+YtJ0toj8A4Z6c/gbrpU4jg/0W5a6Z5X2waSBCsdKOsSLLNJt7Lv7qamvs1sz5gv5432BvUFL0cx9lKxljAtGFoCFwOMLzircPfK+yPMvsxnkt3oCrxkvZlZi5e/2bIIC065QLWGfGrsCCiG16Fgxh/RyS7o6daQhHjfySvbNWrZQ== 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=pQeBP6hVLTmqcFMRKmTRGILHzaF1GoFE+fo7uP0zLv4=; b=HTxhS7OwOViFBwR7cfZUQcvLsXQVysXdRQgpJJ2I/MpAlbb/JaudCPh48edFARM4dBI7TIqXxNyGkpAypx2LpmUtJxeU7ZP3cBhgXUBA0spAsaZ1QEL/5V0Ch+g2qxKUonWKixHcOxGst7/i8dXlIg0QTdAW9x7Lxp2tD7gZA3QAb0DrmYxmpz0NFhYcU7vlSo9RHGIDU06F9N2vhH/H3QKDUZOGoe8NF+ypuV8/VKPmYbbZVR8Py264ecA30zZlDsuBIA9wiS7nI131IF3d3BZ0yYP5ZfIRhPb1Wn5LSelTQrBw472LSXsmvnch92lD5nPoVLhXeZrj/Z3gItdQLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pQeBP6hVLTmqcFMRKmTRGILHzaF1GoFE+fo7uP0zLv4=; b=d2i6GKMIALvuXLSFCuzAJpkUUoXZhkCnB3tLvNU3EJ3IiHEzgtN2UtQu/NNG5g44NexU7xENBa7sV45AdRVGFaJ1/6djNHwMytxbOLenaPMWHjO6RHu6Ow9Wmb/5uA2Mx5SR9MyRRvuR1sE8+nvjMnxXeOWWaapkogsGOLPmBQc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AM7PR04MB7031.eurprd04.prod.outlook.com (2603:10a6:20b:116::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 08:48:39 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617%7]) with mapi id 15.20.6813.027; Thu, 28 Sep 2023 08:48:39 +0000 From: "Radu Pirea (NXP OSS)" To: sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com, hkelam@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, borisp@nvidia.com, saeedm@nvidia.com, leon@kernel.org, sd@queasysnail.net, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, richardcochran@gmail.com, sebastian.tobuschat@oss.nxp.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v6 08/10] net: phy: nxp-c45-tja11xx: add MACsec support Date: Thu, 28 Sep 2023 11:44:28 +0300 Message-Id: <20230928084430.1882670-9-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> References: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1P190CA0018.EURP190.PROD.OUTLOOK.COM (2603:10a6:802:2b::31) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AM7PR04MB7031:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d36a7cb-8dd6-4548-9a7a-08dbbfffa306 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h/VtTpFqiXjUAynNQQL8rqTiIX/vwCdjhZZ95vUAmQ/1RblePoJopO+kmd6uRaT76ui2zlZgL9PPzUquN83dRK+jJi81Lh6tcuFEkozGC+UomgVa9DRpovYQ45SUqQCnAKjO8QguzRkvdWIY5BtbUhSIRpQDn7v+WXERGt4J/psb9Cu4ofeHHKdRedjdoHkbUJfERhGp5rqrrEsEIzauDsjMXKIMhlixTepGZuo+G2CHzhWYWwdjjqsSG4oLlr1yR/WtXp7s7+i5Rx8sSBXTHY216vl/A7EEg331QS7LlmXap5BWeQo7P1TuZtSbtU6n81M7kJjvUKi9XCiUT1asq024lUry+DtPsIBfY076KHy3OLtCRnSCcd29jCK+5vWGyxgRgnEmv943GdFnR4mcE22dZ6WDsQn4vlOStUM9GzCFIdi2Asq5EUhq8siQjClX/dcp7y152cIXMPZh2kze+Wa+trn4I0yNJdNNIzXNerLO3JMmW3JZuZngZxaeU4T0U8BYwjBEwy0SJvyeH1mu5acEM/8kp3OBOv3fGO6WuWJyKKCw2EgnBrd6KQNu8r/ZeBZCjbx+OtjD0djROvL+Hn3jafoMcVGdQVf17va9ua3YiizFSWEZ+WSSxgJfCWGHZR64zrCrNm/0WtDCVN/vNQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(376002)(396003)(39860400002)(366004)(230922051799003)(64100799003)(1800799009)(186009)(451199024)(2906002)(86362001)(30864003)(38350700002)(38100700002)(5660300002)(6512007)(6506007)(52116002)(6666004)(83380400001)(921005)(6486002)(478600001)(4326008)(8936002)(2616005)(41300700001)(7416002)(1076003)(8676002)(26005)(66476007)(66946007)(316002)(6636002)(66556008)(579004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ebjd4hjdAZKRkDHPg5eXrnDjR5dJH4xe79F+AHTPRYMFHjSBE1U4ikfVcxtFkDkNlKl8IRwS1C6gx5FZQgU5Tqz8rA1uKMMapH58Eyz1M40wynIqXoBhfQq3sIfuHx3y0vtnc3MHCivg80pOd5r3kSvf172itzUpGaluA/ZrHujamEo4prC4j2EQJYQrXyy/c+0iLz7SDiOUp7taNZfV8YvFbHF0e1hChrSxZr1o4j3ilXNlrkHxj1ZuHm4AGIDsHqkQLna3tIhr2dePL3RMsW6HG5K1DKmS4wag+whotU3Gll8VdvaYxkLbMzazHMW2qeiueuNPRgWVV+M5q3ArV/SkTXMLBYDIl91/2SsSguilKtzohricdKQadPI05xT0a1p/BLLWKSgg7mmTmvnEbCSTLkjte/X1MfOfkxBaa7U8YMsgd2SYEiFhrXO3j3IaJUjIFboI/f/THmy6z1+0sHTGnIv9n56O+jssE8zQP9b7hoXyhnn3PYCZ3pYr9gqpBW1BVnJ69u98g0KBzgv9FK8BiEkwaPZbMzfyxTcUtkrotBUcRydbd+GjTpe34UkOQNkrX/wEPGWB4ND7IykaFmxs1qagOrpFhommTIsLJuZaXcJBDFz3AlycZIGdzDKSd96SDGnuL4J6YPThVi0QbAhyT0vp1DoYy+s/zU0DtyGi9XjI2EPhjMwcFlJ6dfQ9Il/h4bww0YI2TXGEFQ8bu3MifkFDfD4h0IPGktcp2sM3i77tS+6K0X7HskZj4i3QhfN3ja3S3RooYMK7jpCyalB4SCTbFfFKM9BtiossfN0mdwp4X02F4guXiG7x2HnO8Mj5Q9mqipUKNYlE9WU7GJhThOSOC7tZY1jzhyDMxzwRmGL5XovFEX+mxLuG5bOZ2Ob/o1JaWLgRizipJKUCCgOpz07hGBJSiqmQ7zzxNaIjw6CO6kq0UenZ39KPEsc1T/nIYVUiDTvUO3V6DYAHEtc2zxIX0HS38oPB7MNuRukMf1Htsz0GU0/k442yrdc42/sgeur8D3Az8Yegwhx7GvM/+wrh4euvFGhk5LXF8ImekeeGEu8NfexkFLlF5T1Wga5/TEPu1Ai2jG3S94ZbF9X9M0bP/Lm5HYO2NKvkQ8Kp+KbH6JnjRG6+LRUa9gaTuhHYqypAGwiq4xmQxb+lypyeJ2mK1o2Ia/s658QIIiEKoHhWlaTWx4G3BmA3S2mh6IM9gKFM1kUa89W4sMPvRuzSYpjo867H9Z7WDSGEySs3nn49fFMf0lAuEQlPZzWHf61YoTO/ISoqPpat9Oee08WsUOb5Ht2KXMvwVbI5Ko4U4Tq7kUPdwmr9D8R1mYaz0uD7yg/TxEkCgInKY9Lww+HgWLdSIbC+ZHNXD+xTkLxeGXuZtKtQ3kURjwtjyduRIyHGon4KB5xFy/2Vx5egvjd3QjG0UcQmaYyQFCFxjxPRcsNJCMYTGLKHvpO4sTEpXf9adyVFyWi+rQjAQMB0OoaM7xePuxIvk89FwU3QtERoAzAhL4Ekli2D05dRMRMTS9tyTCBOXYlY2oFO/Yyo+14WihPQI67TwcaAD5+2FtN9ruk746vEziUAaiRPtOCFxv837uWOkmP7jO2YJOgu5g== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d36a7cb-8dd6-4548-9a7a-08dbbfffa306 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 08:48:07.7699 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OjeVtRx2Gcuv04VnyaHFaPfVML2L2hO9NS/pBB8LcyVDx5ytVy+pYTAc/BkdusVefhNzjBwSbw7Zzf7Z3pqw5+vAcOmPHQTYGjjGNi2CPkg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7031 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add MACsec support. The MACsec block has four TX SCs and four RX SCs. The driver supports up to four SecY. Each SecY with one TX SC and one RX SC. The RX SCs can have two keys, key A and key B, written in hardware and enabled at the same time. The TX SCs can have two keys written in hardware, but only one can be active at a given time. On TX, the SC is selected using the MAC source address. Due of this selection mechanism, each offloaded netdev must have a unique MAC address. On RX, the SC is selected by SCI(found in SecTAG or calculated using MAC SA), or using RX SC 0 as implicit. Signed-off-by: Radu Pirea (NXP OSS) --- Changes in v6: - none Changes in V5: - added nxp_c45_secy_irq_en helper to enable and disable the irqs and replaced the irq enable/disable sequence from nxp_c45_mdo_add_secy/nxp_c45_mdo_del_secy with it - changed nxp_c45_tx_sc_set_flt parameters. macsec_context and secy_id replaced with phy_device and nxp_c45_secy pointers. - nxp_c45_mdo_dev_open/nxp_c45_mdo_dev_stop - priv is get from phydev->priv instead of ctx->phydev->priv - nxp_c45_sa_set_key - nxp_c45_macsec_write call uses phydev(local variable) instead of ctx->phydev Changes in V4: - Added nxp_c45_secy_free. - Added nxp_c45_macsec_en. - Added nxp_c45_macsec_remove. - nxp_c45_sa_set_pn does if the pn is 0. validate_upd_sa checks this. - check ctx->sa.update_pn flag before updating next_pn. - nxp_c45_macsec_config_init and nxp_c45_handle_macsec_interrupt are checking priv->macsec instead of phydev->macsec_ops to check if macsec is offloaded. - nxp_c45_handle_macsec_interrupt - replaced WARN_ON(!sa) with WARN_ON(1). sa is either -err_value or a valid pointer and WARN_ON was doing nothing. - nxp_c45_tx_sa_update does not check if (sa->an != encoding_sa). encoding_sa removed from parameters list. - nxp_c45_mdo_upd/del_txsa updates the sa status only if sa->an == encoding_sa - nxp_c45_mdo_add_rxsc - apply RX SCI restrictions only if end_station is true Changes in v3: - removed struct nxp_c45_rx_sc - replaced struct nxp_c45_tx_sa with struct nxp_c45_sa - reworked the implementation around struct nxp_c45_sa - various renamings - tried to better group the functions by SA type/SC type - no key is stored in the driver - TX SAs limited to 2 insted of 4(no key in the driver consequence) - used sci_to_cpu where in various functions - improved debug information - nxp_c45_secy_valid function reworked - merged TX/RX SA set key functions - merged TX/RX SA set pn functions - tried to stick to tx_sa/rx_sa/rx_sc/tx_sc function naming. - nxp_c45_macsec_config_init will return an error if a write fails. - MACSEC_TXSC_CFG_SCI renamed to MACSEC_TXSC_CFG_SCB - return -ENOSPC if no SC/SA available in the hardware - phydev->macsec allocated using devm_kzalloc - changed name of the driver object file Changes in v2: - WARN_ON_ONCE if reg address is not properly aligned - improved patch description MAINTAINERS | 2 +- drivers/net/phy/Kconfig | 2 +- drivers/net/phy/Makefile | 6 +- drivers/net/phy/nxp-c45-tja11xx-macsec.c | 1338 ++++++++++++++++++++++ drivers/net/phy/nxp-c45-tja11xx.c | 77 +- drivers/net/phy/nxp-c45-tja11xx.h | 62 + 6 files changed, 1454 insertions(+), 33 deletions(-) create mode 100644 drivers/net/phy/nxp-c45-tja11xx-macsec.c create mode 100644 drivers/net/phy/nxp-c45-tja11xx.h diff --git a/MAINTAINERS b/MAINTAINERS index 8985a1b0b5ee..b81cf83a1a50 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15309,7 +15309,7 @@ NXP C45 TJA11XX PHY DRIVER M: Radu Pirea L: netdev@vger.kernel.org S: Maintained -F: drivers/net/phy/nxp-c45-tja11xx.c +F: drivers/net/phy/nxp-c45-tja11xx* NXP FSPI DRIVER M: Han Xu diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 107880d13d21..79f54f773af2 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -306,7 +306,7 @@ config NXP_C45_TJA11XX_PHY depends on PTP_1588_CLOCK_OPTIONAL help Enable support for NXP C45 TJA11XX PHYs. - Currently supports the TJA1103 and TJA1120 PHYs. + Currently supports the TJA1103, TJA1104 and TJA1120 PHYs. config NXP_TJA11XX_PHY tristate "NXP TJA11xx PHYs support" diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index c945ed9bd14b..62b42f0d6a85 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -83,7 +83,11 @@ obj-$(CONFIG_MICROSEMI_PHY) += mscc/ obj-$(CONFIG_MOTORCOMM_PHY) += motorcomm.o obj-$(CONFIG_NATIONAL_PHY) += national.o obj-$(CONFIG_NCN26000_PHY) += ncn26000.o -obj-$(CONFIG_NXP_C45_TJA11XX_PHY) += nxp-c45-tja11xx.o +nxp-c45-tja-objs += nxp-c45-tja11xx.o +ifdef CONFIG_MACSEC +nxp-c45-tja-objs += nxp-c45-tja11xx-macsec.o +endif +obj-$(CONFIG_NXP_C45_TJA11XX_PHY) += nxp-c45-tja.o obj-$(CONFIG_NXP_CBTX_PHY) += nxp-cbtx.o obj-$(CONFIG_NXP_TJA11XX_PHY) += nxp-tja11xx.o obj-$(CONFIG_QSEMI_PHY) += qsemi.o diff --git a/drivers/net/phy/nxp-c45-tja11xx-macsec.c b/drivers/net/phy/nxp-c45-tja11xx-macsec.c new file mode 100644 index 000000000000..821f8926f7f2 --- /dev/null +++ b/drivers/net/phy/nxp-c45-tja11xx-macsec.c @@ -0,0 +1,1338 @@ +// SPDX-License-Identifier: GPL-2.0 +/* NXP C45 PTP PHY driver interface + * Copyright 2023 NXP + * Author: Radu Pirea + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nxp-c45-tja11xx.h" + +#define MACSEC_REG_SIZE 32 +#define TX_SC_MAX 4 + +#define TX_SC_BIT(secy_id) BIT(MACSEC_REG_SIZE - (secy_id) - 1) + +#define VEND1_MACSEC_BASE 0x9000 + +#define MACSEC_CFG 0x0000 +#define MACSEC_CFG_BYPASS BIT(1) +#define MACSEC_CFG_S0I BIT(0) + +#define MACSEC_TPNET 0x0044 +#define PN_WRAP_THRESHOLD 0xffffffff + +#define MACSEC_RXSCA 0x0080 +#define MACSEC_RXSCKA 0x0084 + +#define MACSEC_TXSCA 0x00C0 +#define MACSEC_TXSCKA 0x00C4 + +#define MACSEC_RXSC_SCI_1H 0x0100 + +#define MACSEC_RXSC_CFG 0x0128 +#define MACSEC_RXSC_CFG_XPN BIT(25) +#define MACSEC_RXSC_CFG_AES_256 BIT(24) +#define MACSEC_RXSC_CFG_SCI_EN BIT(11) +#define MACSEC_RXSC_CFG_RP BIT(10) +#define MACSEC_RXSC_CFG_VF_MASK GENMASK(9, 8) +#define MACSEC_RXSC_CFG_VF_OFF 8 + +#define MACSEC_RPW 0x012C + +#define MACSEC_RXSA_A_CS 0x0180 +#define MACSEC_RXSA_A_NPN 0x0184 +#define MACSEC_RXSA_A_XNPN 0x0188 +#define MACSEC_RXSA_A_LNPN 0x018C +#define MACSEC_RXSA_A_LXNPN 0x0190 + +#define MACSEC_RXSA_B_CS 0x01C0 +#define MACSEC_RXSA_B_NPN 0x01C4 +#define MACSEC_RXSA_B_XNPN 0x01C8 +#define MACSEC_RXSA_B_LNPN 0x01CC +#define MACSEC_RXSA_B_LXNPN 0x01D0 + +#define MACSEC_RXSA_CS_AN_OFF 1 +#define MACSEC_RXSA_CS_EN BIT(0) + +#define MACSEC_TXSC_SCI_1H 0x0200 +#define MACSEC_TXSC_CFG 0x0228 +#define MACSEC_TXSC_CFG_XPN BIT(25) +#define MACSEC_TXSC_CFG_AES_256 BIT(24) +#define MACSEC_TXSC_CFG_AN_MASK GENMASK(19, 18) +#define MACSEC_TXSC_CFG_AN_OFF 18 +#define MACSEC_TXSC_CFG_ASA BIT(17) +#define MACSEC_TXSC_CFG_SCE BIT(16) +#define MACSEC_TXSC_CFG_ENCRYPT BIT(4) +#define MACSEC_TXSC_CFG_PROTECT BIT(3) +#define MACSEC_TXSC_CFG_SEND_SCI BIT(2) +#define MACSEC_TXSC_CFG_END_STATION BIT(1) +#define MACSEC_TXSC_CFG_SCB BIT(0) + +#define MACSEC_TXSA_A_CS 0x0280 +#define MACSEC_TXSA_A_NPN 0x0284 +#define MACSEC_TXSA_A_XNPN 0x0288 + +#define MACSEC_TXSA_B_CS 0x02C0 +#define MACSEC_TXSA_B_NPN 0x02C4 +#define MACSEC_TXSA_B_XNPN 0x02C8 + +#define MACSEC_SA_CS_A BIT(31) + +#define MACSEC_EVR 0x0400 +#define MACSEC_EVER 0x0404 + +#define MACSEC_RXSA_A_KA 0x0700 +#define MACSEC_RXSA_A_SSCI 0x0720 +#define MACSEC_RXSA_A_SALT 0x0724 + +#define MACSEC_RXSA_B_KA 0x0740 +#define MACSEC_RXSA_B_SSCI 0x0760 +#define MACSEC_RXSA_B_SALT 0x0764 + +#define MACSEC_TXSA_A_KA 0x0780 +#define MACSEC_TXSA_A_SSCI 0x07A0 +#define MACSEC_TXSA_A_SALT 0x07A4 + +#define MACSEC_TXSA_B_KA 0x07C0 +#define MACSEC_TXSA_B_SSCI 0x07E0 +#define MACSEC_TXSA_B_SALT 0x07E4 + +#define MACSEC_UPFR0D2 0x0A08 +#define MACSEC_UPFR0M1 0x0A10 +#define MACSEC_OVP BIT(12) + +#define MACSEC_UPFR0M2 0x0A14 +#define ETYPE_MASK 0xffff + +#define MACSEC_UPFR0R 0x0A18 +#define MACSEC_UPFR_EN BIT(0) + +#define ADPTR_CNTRL 0x0F00 +#define ADPTR_CNTRL_CONFIG_EN BIT(14) +#define ADPTR_CNTRL_ADPTR_EN BIT(12) + +#define TX_SC_FLT_BASE 0x800 +#define TX_SC_FLT_SIZE 0x10 +#define TX_FLT_BASE(flt_id) (TX_SC_FLT_BASE + \ + TX_SC_FLT_SIZE * (flt_id)) + +#define TX_SC_FLT_OFF_MAC_DA_SA 0x04 +#define TX_SC_FLT_OFF_MAC_SA 0x08 +#define TX_SC_FLT_OFF_MAC_CFG 0x0C +#define TX_SC_FLT_BY_SA BIT(14) +#define TX_SC_FLT_EN BIT(8) + +#define TX_SC_FLT_MAC_DA_SA(base) ((base) + TX_SC_FLT_OFF_MAC_DA_SA) +#define TX_SC_FLT_MAC_SA(base) ((base) + TX_SC_FLT_OFF_MAC_SA) +#define TX_SC_FLT_MAC_CFG(base) ((base) + TX_SC_FLT_OFF_MAC_CFG) + +#define ADAPTER_EN BIT(6) +#define MACSEC_EN BIT(5) + +enum nxp_c45_sa_type { + TX_SA, + RX_SA, +}; + +struct nxp_c45_sa { + void *sa; + const struct nxp_c45_sa_regs *regs; + enum nxp_c45_sa_type type; + bool is_key_a; + u8 an; + struct list_head list; +}; + +struct nxp_c45_secy { + struct macsec_secy *secy; + struct macsec_rx_sc *rx_sc; + struct list_head sa_list; + int secy_id; + bool rx_sc0_impl; + struct list_head list; +}; + +struct nxp_c45_macsec { + struct list_head secy_list; + DECLARE_BITMAP(secy_bitmap, TX_SC_MAX); + DECLARE_BITMAP(tx_sc_bitmap, TX_SC_MAX); +}; + +struct nxp_c45_sa_regs { + u16 cs; + u16 npn; + u16 xnpn; + u16 lnpn; + u16 lxnpn; + u16 ka; + u16 ssci; + u16 salt; +}; + +static const struct nxp_c45_sa_regs rx_sa_a_regs = { + .cs = MACSEC_RXSA_A_CS, + .npn = MACSEC_RXSA_A_NPN, + .xnpn = MACSEC_RXSA_A_XNPN, + .lnpn = MACSEC_RXSA_A_LNPN, + .lxnpn = MACSEC_RXSA_A_LXNPN, + .ka = MACSEC_RXSA_A_KA, + .ssci = MACSEC_RXSA_A_SSCI, + .salt = MACSEC_RXSA_A_SALT, +}; + +static const struct nxp_c45_sa_regs rx_sa_b_regs = { + .cs = MACSEC_RXSA_B_CS, + .npn = MACSEC_RXSA_B_NPN, + .xnpn = MACSEC_RXSA_B_XNPN, + .lnpn = MACSEC_RXSA_B_LNPN, + .lxnpn = MACSEC_RXSA_B_LXNPN, + .ka = MACSEC_RXSA_B_KA, + .ssci = MACSEC_RXSA_B_SSCI, + .salt = MACSEC_RXSA_B_SALT, +}; + +static const struct nxp_c45_sa_regs tx_sa_a_regs = { + .cs = MACSEC_TXSA_A_CS, + .npn = MACSEC_TXSA_A_NPN, + .xnpn = MACSEC_TXSA_A_XNPN, + .ka = MACSEC_TXSA_A_KA, + .ssci = MACSEC_TXSA_A_SSCI, + .salt = MACSEC_TXSA_A_SALT, +}; + +static const struct nxp_c45_sa_regs tx_sa_b_regs = { + .cs = MACSEC_TXSA_B_CS, + .npn = MACSEC_TXSA_B_NPN, + .xnpn = MACSEC_TXSA_B_XNPN, + .ka = MACSEC_TXSA_B_KA, + .ssci = MACSEC_TXSA_B_SSCI, + .salt = MACSEC_TXSA_B_SALT, +}; + +static const +struct nxp_c45_sa_regs *nxp_c45_sa_regs_get(enum nxp_c45_sa_type sa_type, + bool key_a) +{ + if (sa_type == RX_SA) + if (key_a) + return &rx_sa_a_regs; + else + return &rx_sa_b_regs; + else if (sa_type == TX_SA) + if (key_a) + return &tx_sa_a_regs; + else + return &tx_sa_b_regs; + else + return NULL; +} + +static int nxp_c45_macsec_write(struct phy_device *phydev, u16 addr, u32 value) +{ + u32 lvalue = value; + u16 laddr; + int ret; + + WARN_ON_ONCE(addr % 4); + + phydev_dbg(phydev, "write addr 0x%x value 0x%x\n", addr, value); + + laddr = VEND1_MACSEC_BASE + addr / 2; + ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, laddr, lvalue); + if (ret) + return ret; + + laddr += 1; + lvalue >>= 16; + ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, laddr, lvalue); + + return ret; +} + +static int nxp_c45_macsec_read(struct phy_device *phydev, u16 addr, u32 *value) +{ + u32 lvalue; + u16 laddr; + int ret; + + WARN_ON_ONCE(addr % 4); + + laddr = VEND1_MACSEC_BASE + addr / 2; + ret = phy_read_mmd(phydev, MDIO_MMD_VEND2, laddr); + if (ret < 0) + return ret; + + laddr += 1; + lvalue = (u32)ret & 0xffff; + ret = phy_read_mmd(phydev, MDIO_MMD_VEND2, laddr); + if (ret < 0) + return ret; + + lvalue |= (u32)ret << 16; + *value = lvalue; + + phydev_dbg(phydev, "read addr 0x%x value 0x%x\n", addr, *value); + + return 0; +} + +static void nxp_c45_secy_irq_en(struct phy_device *phydev, + struct nxp_c45_secy *phy_secy, bool en) +{ + u32 reg; + + nxp_c45_macsec_read(phydev, MACSEC_EVER, ®); + if (en) + reg |= TX_SC_BIT(phy_secy->secy_id); + else + reg &= ~TX_SC_BIT(phy_secy->secy_id); + nxp_c45_macsec_write(phydev, MACSEC_EVER, reg); +} + +static struct nxp_c45_secy *nxp_c45_find_secy(struct list_head *secy_list, + sci_t sci) +{ + struct nxp_c45_secy *pos, *tmp; + + list_for_each_entry_safe(pos, tmp, secy_list, list) + if (pos->secy->sci == sci) + return pos; + + return ERR_PTR(-EINVAL); +} + +static void nxp_c45_secy_free(struct nxp_c45_secy *phy_secy) +{ + list_del(&phy_secy->list); + kfree(phy_secy); +} + +static struct nxp_c45_sa *nxp_c45_find_sa(struct list_head *sa_list, + enum nxp_c45_sa_type sa_type, u8 an) +{ + struct nxp_c45_sa *pos, *tmp; + + list_for_each_entry_safe(pos, tmp, sa_list, list) + if (pos->an == an && pos->type == sa_type) + return pos; + + return ERR_PTR(-EINVAL); +} + +static struct nxp_c45_sa *nxp_c45_sa_alloc(struct list_head *sa_list, void *sa, + enum nxp_c45_sa_type sa_type, u8 an) +{ + struct nxp_c45_sa *first = NULL, *pos, *tmp; + int ocurences = 0; + + list_for_each_entry_safe(pos, tmp, sa_list, list) { + if (pos->type != sa_type) + continue; + + if (pos->an == an) + return ERR_PTR(-EINVAL); + + first = pos; + ocurences++; + if (ocurences >= 2) + return ERR_PTR(-ENOSPC); + } + + tmp = kzalloc(sizeof(*tmp), GFP_KERNEL); + if (!tmp) + return ERR_PTR(-ENOMEM); + + if (first) + tmp->is_key_a = !first->is_key_a; + else + tmp->is_key_a = true; + + tmp->sa = sa; + tmp->type = sa_type; + tmp->an = an; + tmp->regs = nxp_c45_sa_regs_get(tmp->type, tmp->is_key_a); + list_add_tail(&tmp->list, sa_list); + + return tmp; +} + +static void nxp_c45_sa_free(struct nxp_c45_sa *sa) +{ + list_del(&sa->list); + kfree_sensitive(sa); +} + +static void nxp_c45_sa_list_free(struct list_head *sa_list) +{ + struct nxp_c45_sa *pos, *tmp; + + list_for_each_entry_safe(pos, tmp, sa_list, list) + nxp_c45_sa_free(pos); +} + +static void nxp_c45_sa_set_pn(struct phy_device *phydev, + struct nxp_c45_sa *sa, u64 pn, + u32 replay_window) +{ + const struct nxp_c45_sa_regs *sa_regs = sa->regs; + pn_t npn = {.full64 = pn}; + pn_t lnpn; + + nxp_c45_macsec_write(phydev, sa_regs->npn, npn.lower); + nxp_c45_macsec_write(phydev, sa_regs->xnpn, npn.upper); + if (sa->type != RX_SA) + return; + + if (pn > replay_window) + lnpn.full64 = pn - replay_window; + else + lnpn.full64 = 1; + + nxp_c45_macsec_write(phydev, sa_regs->lnpn, lnpn.lower); + nxp_c45_macsec_write(phydev, sa_regs->lxnpn, lnpn.upper); +} + +static void nxp_c45_sa_set_key(struct macsec_context *ctx, + const struct nxp_c45_sa_regs *sa_regs, + u8 *salt, ssci_t ssci) +{ + struct phy_device *phydev = ctx->phydev; + u32 key_size = ctx->secy->key_len / 4; + u32 salt_size = MACSEC_SALT_LEN / 4; + u32 *key_u32 = (u32 *)ctx->sa.key; + u32 *salt_u32 = (u32 *)salt; + u32 reg, value; + int i; + + for (i = 0; i < key_size; i++) { + reg = sa_regs->ka + i * 4; + value = (__force u32)cpu_to_be32(key_u32[i]); + nxp_c45_macsec_write(phydev, reg, value); + } + + if (ctx->secy->xpn) { + for (i = 0; i < salt_size; i++) { + reg = sa_regs->salt + (2 - i) * 4; + value = (__force u32)cpu_to_be32(salt_u32[i]); + nxp_c45_macsec_write(phydev, reg, value); + } + + value = (__force u32)cpu_to_be32((__force u32)ssci); + nxp_c45_macsec_write(phydev, sa_regs->ssci, value); + } + + nxp_c45_macsec_write(phydev, sa_regs->cs, MACSEC_SA_CS_A); +} + +static void nxp_c45_rx_sa_update(struct phy_device *phydev, + struct nxp_c45_sa *sa, bool en) +{ + const struct nxp_c45_sa_regs *sa_regs = sa->regs; + u32 cfg; + + cfg = sa->an << MACSEC_RXSA_CS_AN_OFF; + cfg |= en ? MACSEC_RXSA_CS_EN : 0; + nxp_c45_macsec_write(phydev, sa_regs->cs, cfg); +} + +static void nxp_c45_tx_sa_update(struct phy_device *phydev, + struct nxp_c45_sa *sa, bool en) +{ + u32 cfg = 0; + + nxp_c45_macsec_read(phydev, MACSEC_TXSC_CFG, &cfg); + + cfg &= ~MACSEC_TXSC_CFG_AN_MASK; + cfg |= sa->an << MACSEC_TXSC_CFG_AN_OFF; + + if (sa->is_key_a) + cfg &= ~MACSEC_TXSC_CFG_ASA; + else + cfg |= MACSEC_TXSC_CFG_ASA; + + if (en) + cfg |= MACSEC_TXSC_CFG_SCE; + else + cfg &= ~MACSEC_TXSC_CFG_SCE; + + nxp_c45_macsec_write(phydev, MACSEC_TXSC_CFG, cfg); +} + +static void nxp_c45_set_sci(struct phy_device *phydev, u16 sci_base_addr, + sci_t sci) +{ + u64 lsci = sci_to_cpu(sci); + + nxp_c45_macsec_write(phydev, sci_base_addr, lsci >> 32); + nxp_c45_macsec_write(phydev, sci_base_addr + 4, lsci); +} + +static bool nxp_c45_sci_valid(sci_t sci, bool scb) +{ + u16 port = sci_to_cpu(sci); + + if (scb && port != 0) + return false; + if (!scb && port != 1) + return false; + + return true; +} + +static void nxp_c45_select_secy(struct phy_device *phydev, u8 id) +{ + nxp_c45_macsec_write(phydev, MACSEC_RXSCA, id); + nxp_c45_macsec_write(phydev, MACSEC_RXSCKA, id); + nxp_c45_macsec_write(phydev, MACSEC_TXSCA, id); + nxp_c45_macsec_write(phydev, MACSEC_TXSCKA, id); +} + +static bool nxp_c45_secy_valid(struct nxp_c45_secy *phy_secy, + bool can_rx_sc0_impl) +{ + bool end_station = phy_secy->secy->tx_sc.end_station; + bool send_sci = phy_secy->secy->tx_sc.send_sci; + bool scb = phy_secy->secy->tx_sc.scb; + bool rx_sci_valid, tx_sci_valid; + sci_t sci = phy_secy->secy->sci; + + phy_secy->rx_sc0_impl = false; + + if (send_sci) { + if (end_station || scb) + return false; + else + return true; + } + + if (end_station) { + tx_sci_valid = nxp_c45_sci_valid(sci, scb); + if (phy_secy->rx_sc) { + sci = phy_secy->rx_sc->sci; + rx_sci_valid = nxp_c45_sci_valid(sci, scb); + } else { + rx_sci_valid = true; + } + + return tx_sci_valid && rx_sci_valid; + } + + if (scb) + return false; + + if (!can_rx_sc0_impl) + return false; + + if (phy_secy->secy_id != 0) + return false; + + phy_secy->rx_sc0_impl = true; + + return true; +} + +static bool nxp_c45_mac_addr_free(struct macsec_context *ctx) +{ + struct nxp_c45_phy *priv = ctx->phydev->priv; + struct nxp_c45_secy *pos, *tmp; + + list_for_each_entry_safe(pos, tmp, &priv->macsec->secy_list, list) { + if (pos->secy == ctx->secy) + continue; + + if (memcmp(pos->secy->netdev->dev_addr, + ctx->secy->netdev->dev_addr, ETH_ALEN) == 0) + return false; + } + + return true; +} + +static void nxp_c45_tx_sc_en_flt(struct phy_device *phydev, int secy_id, + bool en) +{ + u32 tx_flt_base = TX_FLT_BASE(secy_id); + u32 reg = 0; + + nxp_c45_macsec_read(phydev, TX_SC_FLT_MAC_CFG(tx_flt_base), ®); + if (en) + reg |= TX_SC_FLT_EN; + else + reg &= ~TX_SC_FLT_EN; + nxp_c45_macsec_write(phydev, TX_SC_FLT_MAC_CFG(tx_flt_base), reg); +} + +static void nxp_c45_tx_sc_set_flt(struct phy_device *phydev, + struct nxp_c45_secy *phy_secy) +{ + const u8 *dev_addr = phy_secy->secy->netdev->dev_addr; + u32 tx_flt_base = TX_FLT_BASE(phy_secy->secy_id); + u32 reg; + + reg = dev_addr[0] << 8 | dev_addr[1]; + nxp_c45_macsec_write(phydev, TX_SC_FLT_MAC_DA_SA(tx_flt_base), reg); + reg = dev_addr[5] | dev_addr[4] << 8 | dev_addr[3] << 16 | + dev_addr[2] << 24; + + nxp_c45_macsec_write(phydev, TX_SC_FLT_MAC_SA(tx_flt_base), reg); + nxp_c45_macsec_read(phydev, TX_SC_FLT_MAC_CFG(tx_flt_base), ®); + reg &= TX_SC_FLT_EN; + reg |= TX_SC_FLT_BY_SA | phy_secy->secy_id; + nxp_c45_macsec_write(phydev, TX_SC_FLT_MAC_CFG(tx_flt_base), reg); +} + +static void nxp_c45_tx_sc_update(struct phy_device *phydev, + struct nxp_c45_secy *phy_secy) +{ + u32 cfg = 0; + + nxp_c45_macsec_read(phydev, MACSEC_TXSC_CFG, &cfg); + + phydev_dbg(phydev, "XPN %s\n", phy_secy->secy->xpn ? "on" : "off"); + if (phy_secy->secy->xpn) + cfg |= MACSEC_TXSC_CFG_XPN; + else + cfg &= ~MACSEC_TXSC_CFG_XPN; + + phydev_dbg(phydev, "key len %u\n", phy_secy->secy->key_len); + if (phy_secy->secy->key_len == 32) + cfg |= MACSEC_TXSC_CFG_AES_256; + else + cfg &= ~MACSEC_TXSC_CFG_AES_256; + + phydev_dbg(phydev, "encryption %s\n", + phy_secy->secy->tx_sc.encrypt ? "on" : "off"); + if (phy_secy->secy->tx_sc.encrypt) + cfg |= MACSEC_TXSC_CFG_ENCRYPT; + else + cfg &= ~MACSEC_TXSC_CFG_ENCRYPT; + + phydev_dbg(phydev, "protect frames %s\n", + phy_secy->secy->protect_frames ? "on" : "off"); + if (phy_secy->secy->protect_frames) + cfg |= MACSEC_TXSC_CFG_PROTECT; + else + cfg &= ~MACSEC_TXSC_CFG_PROTECT; + + phydev_dbg(phydev, "send sci %s\n", + phy_secy->secy->tx_sc.send_sci ? "on" : "off"); + if (phy_secy->secy->tx_sc.send_sci) + cfg |= MACSEC_TXSC_CFG_SEND_SCI; + else + cfg &= ~MACSEC_TXSC_CFG_SEND_SCI; + + phydev_dbg(phydev, "end station %s\n", + phy_secy->secy->tx_sc.end_station ? "on" : "off"); + if (phy_secy->secy->tx_sc.end_station) + cfg |= MACSEC_TXSC_CFG_END_STATION; + else + cfg &= ~MACSEC_TXSC_CFG_END_STATION; + + phydev_dbg(phydev, "scb %s\n", + phy_secy->secy->tx_sc.scb ? "on" : "off"); + if (phy_secy->secy->tx_sc.scb) + cfg |= MACSEC_TXSC_CFG_SCB; + else + cfg &= ~MACSEC_TXSC_CFG_SCB; + + nxp_c45_macsec_write(phydev, MACSEC_TXSC_CFG, cfg); +} + +static void nxp_c45_set_rx_sc0_impl(struct phy_device *phydev, + bool enable) +{ + u32 reg = 0; + + nxp_c45_macsec_read(phydev, MACSEC_CFG, ®); + if (enable) + reg |= MACSEC_CFG_S0I; + else + reg &= ~MACSEC_CFG_S0I; + nxp_c45_macsec_write(phydev, MACSEC_CFG, reg); +} + +static bool nxp_c45_is_rx_sc0_impl(struct list_head *secy_list) +{ + struct nxp_c45_secy *pos, *tmp; + + list_for_each_entry_safe(pos, tmp, secy_list, list) + if (pos->rx_sc0_impl) + return pos->rx_sc0_impl; + + return false; +} + +static void nxp_c45_rx_sc_en(struct phy_device *phydev, + struct macsec_rx_sc *rx_sc, bool en) +{ + u32 reg = 0; + + nxp_c45_macsec_read(phydev, MACSEC_RXSC_CFG, ®); + if (rx_sc->active && en) + reg |= MACSEC_RXSC_CFG_SCI_EN; + else + reg &= ~MACSEC_RXSC_CFG_SCI_EN; + nxp_c45_macsec_write(phydev, MACSEC_RXSC_CFG, reg); +} + +static void nxp_c45_rx_sc_update(struct phy_device *phydev, + struct nxp_c45_secy *phy_secy) +{ + struct macsec_rx_sc *rx_sc = phy_secy->rx_sc; + struct nxp_c45_phy *priv = phydev->priv; + u32 cfg = 0; + + nxp_c45_macsec_read(phydev, MACSEC_RXSC_CFG, &cfg); + cfg &= ~MACSEC_RXSC_CFG_VF_MASK; + cfg = phy_secy->secy->validate_frames << MACSEC_RXSC_CFG_VF_OFF; + + phydev_dbg(phydev, "validate frames %u\n", + phy_secy->secy->validate_frames); + phydev_dbg(phydev, "replay_protect %s window %u\n", + phy_secy->secy->replay_protect ? "on" : "off", + phy_secy->secy->replay_window); + if (phy_secy->secy->replay_protect) { + cfg |= MACSEC_RXSC_CFG_RP; + if (cfg & MACSEC_RXSC_CFG_SCI_EN) { + phydev_dbg(phydev, "RX SC enabled, window will not be updated\n"); + } else { + phydev_dbg(phydev, "RX SC disabled, window will be updated\n"); + nxp_c45_macsec_write(phydev, MACSEC_RPW, + phy_secy->secy->replay_window); + } + } else { + cfg &= ~MACSEC_RXSC_CFG_RP; + } + + phydev_dbg(phydev, "rx_sc->active %s\n", + rx_sc->active ? "on" : "off"); + if (rx_sc->active && + test_bit(phy_secy->secy_id, priv->macsec->secy_bitmap)) + cfg |= MACSEC_RXSC_CFG_SCI_EN; + else + cfg &= ~MACSEC_RXSC_CFG_SCI_EN; + + phydev_dbg(phydev, "key len %u\n", phy_secy->secy->key_len); + if (phy_secy->secy->key_len == 32) + cfg |= MACSEC_RXSC_CFG_AES_256; + else + cfg &= ~MACSEC_RXSC_CFG_AES_256; + + phydev_dbg(phydev, "XPN %s\n", phy_secy->secy->xpn ? "on" : "off"); + if (phy_secy->secy->xpn) + cfg |= MACSEC_RXSC_CFG_XPN; + else + cfg &= ~MACSEC_RXSC_CFG_XPN; + + nxp_c45_macsec_write(phydev, MACSEC_RXSC_CFG, cfg); +} + +static void nxp_c45_rx_sc_del(struct phy_device *phydev, + struct nxp_c45_secy *phy_secy) +{ + struct nxp_c45_sa *pos, *tmp; + + nxp_c45_macsec_write(phydev, MACSEC_RXSC_CFG, 0); + nxp_c45_macsec_write(phydev, MACSEC_RPW, 0); + nxp_c45_set_sci(phydev, MACSEC_RXSC_SCI_1H, 0); + + list_for_each_entry_safe(pos, tmp, &phy_secy->sa_list, list) + if (pos->type == RX_SA) + nxp_c45_rx_sa_update(phydev, pos, false); +} + +static void nxp_c45_macsec_en(struct phy_device *phydev, bool en) +{ + u32 reg; + + nxp_c45_macsec_read(phydev, MACSEC_CFG, ®); + if (en) + reg |= MACSEC_CFG_BYPASS; + else + reg &= ~MACSEC_CFG_BYPASS; + nxp_c45_macsec_write(phydev, MACSEC_CFG, reg); +} + +static int nxp_c45_mdo_dev_open(struct macsec_context *ctx) +{ + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct nxp_c45_secy *phy_secy; + int any_bit_set; + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + nxp_c45_select_secy(phydev, phy_secy->secy_id); + + nxp_c45_tx_sc_en_flt(phydev, phy_secy->secy_id, true); + nxp_c45_set_rx_sc0_impl(phydev, phy_secy->rx_sc0_impl); + if (phy_secy->rx_sc) + nxp_c45_rx_sc_en(phydev, phy_secy->rx_sc, true); + + any_bit_set = find_first_bit(priv->macsec->secy_bitmap, TX_SC_MAX); + if (any_bit_set == TX_SC_MAX) + nxp_c45_macsec_en(phydev, true); + + set_bit(phy_secy->secy_id, priv->macsec->secy_bitmap); + + return 0; +} + +static int nxp_c45_mdo_dev_stop(struct macsec_context *ctx) +{ + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct nxp_c45_secy *phy_secy; + int any_bit_set; + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + nxp_c45_select_secy(phydev, phy_secy->secy_id); + + nxp_c45_tx_sc_en_flt(phydev, phy_secy->secy_id, false); + if (phy_secy->rx_sc) + nxp_c45_rx_sc_en(phydev, phy_secy->rx_sc, false); + nxp_c45_set_rx_sc0_impl(phydev, false); + + clear_bit(phy_secy->secy_id, priv->macsec->secy_bitmap); + any_bit_set = find_first_bit(priv->macsec->secy_bitmap, TX_SC_MAX); + if (any_bit_set == TX_SC_MAX) + nxp_c45_macsec_en(phydev, false); + + return 0; +} + +static int nxp_c45_mdo_add_secy(struct macsec_context *ctx) +{ + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct nxp_c45_secy *phy_secy; + bool can_rx_sc0_impl; + int idx; + + phydev_dbg(phydev, "add SecY SCI %016llx\n", + sci_to_cpu(ctx->secy->sci)); + + if (!nxp_c45_mac_addr_free(ctx)) + return -EBUSY; + + if (nxp_c45_is_rx_sc0_impl(&priv->macsec->secy_list)) + return -EBUSY; + + idx = find_first_zero_bit(priv->macsec->tx_sc_bitmap, TX_SC_MAX); + if (idx == TX_SC_MAX) + return -ENOSPC; + + phy_secy = kzalloc(sizeof(*phy_secy), GFP_KERNEL); + if (!phy_secy) + return -ENOMEM; + + INIT_LIST_HEAD(&phy_secy->sa_list); + phy_secy->secy = ctx->secy; + phy_secy->secy_id = idx; + + /* If the point to point mode should be enabled, we should have only + * one SecY enabled, respectively the new one. + */ + can_rx_sc0_impl = list_count_nodes(&priv->macsec->secy_list) == 0; + if (!nxp_c45_secy_valid(phy_secy, can_rx_sc0_impl)) { + kfree_sensitive(phy_secy); + return -EINVAL; + } + + nxp_c45_select_secy(phydev, phy_secy->secy_id); + nxp_c45_set_sci(phydev, MACSEC_TXSC_SCI_1H, ctx->secy->sci); + nxp_c45_tx_sc_set_flt(phydev, phy_secy); + nxp_c45_tx_sc_update(phydev, phy_secy); + if (phy_interrupt_is_valid(phydev)) + nxp_c45_secy_irq_en(phydev, phy_secy, true); + + set_bit(idx, priv->macsec->tx_sc_bitmap); + list_add_tail(&phy_secy->list, &priv->macsec->secy_list); + + return 0; +} + +static void nxp_c45_tx_sa_next(struct nxp_c45_secy *phy_secy, + struct nxp_c45_sa *next_sa, u8 encoding_sa) +{ + struct nxp_c45_sa *sa; + + sa = nxp_c45_find_sa(&phy_secy->sa_list, TX_SA, encoding_sa); + if (!IS_ERR(sa)) { + memcpy(next_sa, sa, sizeof(*sa)); + } else { + next_sa->is_key_a = true; + next_sa->an = encoding_sa; + } +} + +static int nxp_c45_mdo_upd_secy(struct macsec_context *ctx) +{ + u8 encoding_sa = ctx->secy->tx_sc.encoding_sa; + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct nxp_c45_secy *phy_secy; + struct nxp_c45_sa next_sa; + bool can_rx_sc0_impl; + + phydev_dbg(phydev, "update SecY SCI %016llx\n", + sci_to_cpu(ctx->secy->sci)); + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + if (!nxp_c45_mac_addr_free(ctx)) + return -EBUSY; + + /* If the point to point mode should be enabled, we should have only + * one SecY enabled, respectively the new one. + */ + can_rx_sc0_impl = list_count_nodes(&priv->macsec->secy_list) == 1; + if (!nxp_c45_secy_valid(phy_secy, can_rx_sc0_impl)) + return -EINVAL; + + nxp_c45_select_secy(phydev, phy_secy->secy_id); + + nxp_c45_tx_sc_set_flt(phydev, phy_secy); + nxp_c45_tx_sc_update(phydev, phy_secy); + + nxp_c45_tx_sa_next(phy_secy, &next_sa, encoding_sa); + nxp_c45_tx_sa_update(phydev, &next_sa, ctx->secy->operational); + + nxp_c45_set_rx_sc0_impl(phydev, phy_secy->rx_sc0_impl); + if (phy_secy->rx_sc) + nxp_c45_rx_sc_update(phydev, phy_secy); + + return 0; +} + +static int nxp_c45_mdo_del_secy(struct macsec_context *ctx) +{ + u8 encoding_sa = ctx->secy->tx_sc.encoding_sa; + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct nxp_c45_secy *phy_secy; + struct nxp_c45_sa next_sa; + + phydev_dbg(phydev, "delete SecY SCI %016llx\n", + sci_to_cpu(ctx->secy->sci)); + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + nxp_c45_select_secy(phydev, phy_secy->secy_id); + + nxp_c45_mdo_dev_stop(ctx); + nxp_c45_tx_sa_next(phy_secy, &next_sa, encoding_sa); + nxp_c45_tx_sa_update(phydev, &next_sa, false); + if (phy_secy->rx_sc) + nxp_c45_rx_sc_del(phydev, phy_secy); + + nxp_c45_sa_list_free(&phy_secy->sa_list); + if (phy_interrupt_is_valid(phydev)) + nxp_c45_secy_irq_en(phydev, phy_secy, false); + + clear_bit(phy_secy->secy_id, priv->macsec->tx_sc_bitmap); + nxp_c45_secy_free(phy_secy); + + return 0; +} + +static int nxp_c45_mdo_add_rxsc(struct macsec_context *ctx) +{ + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct nxp_c45_secy *phy_secy; + + phydev_dbg(phydev, "add RX SC SCI %016llx %s\n", + sci_to_cpu(ctx->rx_sc->sci), + ctx->rx_sc->active ? "enabled" : "disabled"); + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + if (phy_secy->rx_sc) + return -ENOSPC; + + if (phy_secy->secy->tx_sc.end_station && + !nxp_c45_sci_valid(ctx->rx_sc->sci, ctx->secy->tx_sc.scb)) + return -EINVAL; + + phy_secy->rx_sc = ctx->rx_sc; + + nxp_c45_select_secy(phydev, phy_secy->secy_id); + nxp_c45_set_sci(phydev, MACSEC_RXSC_SCI_1H, ctx->rx_sc->sci); + nxp_c45_rx_sc_update(phydev, phy_secy); + + return 0; +} + +static int nxp_c45_mdo_upd_rxsc(struct macsec_context *ctx) +{ + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct nxp_c45_secy *phy_secy; + + phydev_dbg(phydev, "update RX SC SCI %016llx %s\n", + sci_to_cpu(ctx->rx_sc->sci), + ctx->rx_sc->active ? "enabled" : "disabled"); + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + nxp_c45_select_secy(phydev, phy_secy->secy_id); + nxp_c45_rx_sc_update(phydev, phy_secy); + + return 0; +} + +static int nxp_c45_mdo_del_rxsc(struct macsec_context *ctx) +{ + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct nxp_c45_secy *phy_secy; + + phydev_dbg(phydev, "delete RX SC SCI %016llx %s\n", + sci_to_cpu(ctx->rx_sc->sci), + ctx->rx_sc->active ? "enabled" : "disabled"); + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + nxp_c45_select_secy(phydev, phy_secy->secy_id); + nxp_c45_rx_sc_del(phydev, phy_secy); + phy_secy->rx_sc = NULL; + + return 0; +} + +static int nxp_c45_mdo_add_rxsa(struct macsec_context *ctx) +{ + struct macsec_rx_sa *rx_sa = ctx->sa.rx_sa; + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct nxp_c45_secy *phy_secy; + u8 an = ctx->sa.assoc_num; + struct nxp_c45_sa *sa; + + phydev_dbg(phydev, "add RX SA %u %s to RX SC SCI %016llx\n", + an, rx_sa->active ? "enabled" : "disabled", + sci_to_cpu(rx_sa->sc->sci)); + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + sa = nxp_c45_sa_alloc(&phy_secy->sa_list, rx_sa, RX_SA, an); + if (IS_ERR(sa)) + return PTR_ERR(sa); + + nxp_c45_select_secy(phydev, phy_secy->secy_id); + nxp_c45_sa_set_pn(phydev, sa, rx_sa->next_pn, + ctx->secy->replay_window); + nxp_c45_sa_set_key(ctx, sa->regs, rx_sa->key.salt.bytes, rx_sa->ssci); + nxp_c45_rx_sa_update(phydev, sa, rx_sa->active); + + return 0; +} + +static int nxp_c45_mdo_upd_rxsa(struct macsec_context *ctx) +{ + struct macsec_rx_sa *rx_sa = ctx->sa.rx_sa; + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct nxp_c45_secy *phy_secy; + u8 an = ctx->sa.assoc_num; + struct nxp_c45_sa *sa; + + phydev_dbg(phydev, "update RX SA %u %s to RX SC SCI %016llx\n", + an, rx_sa->active ? "enabled" : "disabled", + sci_to_cpu(rx_sa->sc->sci)); + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + sa = nxp_c45_find_sa(&phy_secy->sa_list, RX_SA, an); + if (IS_ERR(sa)) + return PTR_ERR(sa); + + nxp_c45_select_secy(phydev, phy_secy->secy_id); + if (ctx->sa.update_pn) + nxp_c45_sa_set_pn(phydev, sa, rx_sa->next_pn, + ctx->secy->replay_window); + nxp_c45_rx_sa_update(phydev, sa, rx_sa->active); + + return 0; +} + +static int nxp_c45_mdo_del_rxsa(struct macsec_context *ctx) +{ + struct macsec_rx_sa *rx_sa = ctx->sa.rx_sa; + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct nxp_c45_secy *phy_secy; + u8 an = ctx->sa.assoc_num; + struct nxp_c45_sa *sa; + + phydev_dbg(phydev, "delete RX SA %u %s to RX SC SCI %016llx\n", + an, rx_sa->active ? "enabled" : "disabled", + sci_to_cpu(rx_sa->sc->sci)); + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + sa = nxp_c45_find_sa(&phy_secy->sa_list, RX_SA, an); + if (IS_ERR(sa)) + return PTR_ERR(sa); + + nxp_c45_select_secy(phydev, phy_secy->secy_id); + nxp_c45_rx_sa_update(phydev, sa, false); + + nxp_c45_sa_free(sa); + + return 0; +} + +static int nxp_c45_mdo_add_txsa(struct macsec_context *ctx) +{ + struct macsec_tx_sa *tx_sa = ctx->sa.tx_sa; + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct nxp_c45_secy *phy_secy; + u8 an = ctx->sa.assoc_num; + struct nxp_c45_sa *sa; + + phydev_dbg(phydev, "add TX SA %u %s to TX SC %016llx\n", + an, ctx->sa.tx_sa->active ? "enabled" : "disabled", + sci_to_cpu(ctx->secy->sci)); + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + sa = nxp_c45_sa_alloc(&phy_secy->sa_list, tx_sa, TX_SA, an); + if (IS_ERR(sa)) + return PTR_ERR(sa); + + nxp_c45_select_secy(phydev, phy_secy->secy_id); + nxp_c45_sa_set_pn(phydev, sa, tx_sa->next_pn, 0); + nxp_c45_sa_set_key(ctx, sa->regs, tx_sa->key.salt.bytes, tx_sa->ssci); + if (ctx->secy->tx_sc.encoding_sa == sa->an) + nxp_c45_tx_sa_update(phydev, sa, tx_sa->active); + + return 0; +} + +static int nxp_c45_mdo_upd_txsa(struct macsec_context *ctx) +{ + struct macsec_tx_sa *tx_sa = ctx->sa.tx_sa; + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct nxp_c45_secy *phy_secy; + u8 an = ctx->sa.assoc_num; + struct nxp_c45_sa *sa; + + phydev_dbg(phydev, "update TX SA %u %s to TX SC %016llx\n", + an, ctx->sa.tx_sa->active ? "enabled" : "disabled", + sci_to_cpu(ctx->secy->sci)); + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + sa = nxp_c45_find_sa(&phy_secy->sa_list, TX_SA, an); + if (IS_ERR(sa)) + return PTR_ERR(sa); + + nxp_c45_select_secy(phydev, phy_secy->secy_id); + if (ctx->sa.update_pn) + nxp_c45_sa_set_pn(phydev, sa, tx_sa->next_pn, 0); + if (ctx->secy->tx_sc.encoding_sa == sa->an) + nxp_c45_tx_sa_update(phydev, sa, tx_sa->active); + + return 0; +} + +static int nxp_c45_mdo_del_txsa(struct macsec_context *ctx) +{ + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct nxp_c45_secy *phy_secy; + u8 an = ctx->sa.assoc_num; + struct nxp_c45_sa *sa; + + phydev_dbg(phydev, "delete TX SA %u %s to TX SC %016llx\n", + an, ctx->sa.tx_sa->active ? "enabled" : "disabled", + sci_to_cpu(ctx->secy->sci)); + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + sa = nxp_c45_find_sa(&phy_secy->sa_list, TX_SA, an); + if (IS_ERR(sa)) + return PTR_ERR(sa); + + nxp_c45_select_secy(phydev, phy_secy->secy_id); + if (ctx->secy->tx_sc.encoding_sa == sa->an) + nxp_c45_tx_sa_update(phydev, sa, false); + + nxp_c45_sa_free(sa); + + return 0; +} + +static const struct macsec_ops nxp_c45_macsec_ops = { + .mdo_dev_open = nxp_c45_mdo_dev_open, + .mdo_dev_stop = nxp_c45_mdo_dev_stop, + .mdo_add_secy = nxp_c45_mdo_add_secy, + .mdo_upd_secy = nxp_c45_mdo_upd_secy, + .mdo_del_secy = nxp_c45_mdo_del_secy, + .mdo_add_rxsc = nxp_c45_mdo_add_rxsc, + .mdo_upd_rxsc = nxp_c45_mdo_upd_rxsc, + .mdo_del_rxsc = nxp_c45_mdo_del_rxsc, + .mdo_add_rxsa = nxp_c45_mdo_add_rxsa, + .mdo_upd_rxsa = nxp_c45_mdo_upd_rxsa, + .mdo_del_rxsa = nxp_c45_mdo_del_rxsa, + .mdo_add_txsa = nxp_c45_mdo_add_txsa, + .mdo_upd_txsa = nxp_c45_mdo_upd_txsa, + .mdo_del_txsa = nxp_c45_mdo_del_txsa, +}; + +int nxp_c45_macsec_config_init(struct phy_device *phydev) +{ + struct nxp_c45_phy *priv = phydev->priv; + int ret; + + if (!priv->macsec) + return 0; + + ret = phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_PORT_FUNC_ENABLES, + MACSEC_EN | ADAPTER_EN); + if (ret) + return ret; + + ret = nxp_c45_macsec_write(phydev, ADPTR_CNTRL, ADPTR_CNTRL_CONFIG_EN | + ADPTR_CNTRL_ADPTR_EN); + if (ret) + return ret; + + ret = nxp_c45_macsec_write(phydev, ADPTR_CNTRL, ADPTR_CNTRL_ADPTR_EN); + if (ret) + return ret; + + ret = nxp_c45_macsec_write(phydev, MACSEC_TPNET, PN_WRAP_THRESHOLD); + if (ret) + return ret; + + /* Set MKA filter. */ + ret = nxp_c45_macsec_write(phydev, MACSEC_UPFR0D2, ETH_P_PAE); + if (ret) + return ret; + + ret = nxp_c45_macsec_write(phydev, MACSEC_UPFR0M1, MACSEC_OVP); + if (ret) + return ret; + + ret = nxp_c45_macsec_write(phydev, MACSEC_UPFR0M2, ETYPE_MASK); + if (ret) + return ret; + + ret = nxp_c45_macsec_write(phydev, MACSEC_UPFR0R, MACSEC_UPFR_EN); + + return ret; +} + +int nxp_c45_macsec_probe(struct phy_device *phydev) +{ + struct nxp_c45_phy *priv = phydev->priv; + struct device *dev = &phydev->mdio.dev; + + priv->macsec = devm_kzalloc(dev, sizeof(*priv->macsec), GFP_KERNEL); + if (!priv->macsec) + return -ENOMEM; + + INIT_LIST_HEAD(&priv->macsec->secy_list); + phydev->macsec_ops = &nxp_c45_macsec_ops; + + return 0; +} + +void nxp_c45_macsec_remove(struct phy_device *phydev) +{ + struct nxp_c45_phy *priv = phydev->priv; + struct nxp_c45_secy *secy_p, *secy_t; + struct nxp_c45_sa *sa_p, *sa_t; + struct list_head *secy_list; + + if (!priv->macsec) + return; + + secy_list = &priv->macsec->secy_list; + nxp_c45_macsec_en(phydev, false); + + list_for_each_entry_safe(secy_p, secy_t, secy_list, list) { + list_for_each_entry_safe(sa_p, sa_t, &secy_p->sa_list, list) + nxp_c45_sa_free(sa_p); + nxp_c45_secy_free(secy_p); + } +} + +void nxp_c45_handle_macsec_interrupt(struct phy_device *phydev, + irqreturn_t *ret) +{ + struct nxp_c45_phy *priv = phydev->priv; + struct nxp_c45_secy *pos, *tmp; + struct nxp_c45_sa *sa; + u8 encoding_sa; + int secy_id; + u32 reg = 0; + + if (!priv->macsec) + return; + + do { + nxp_c45_macsec_read(phydev, MACSEC_EVR, ®); + if (!reg) + return; + + secy_id = MACSEC_REG_SIZE - ffs(reg); + list_for_each_entry_safe(pos, tmp, &priv->macsec->secy_list, + list) + if (pos->secy_id == secy_id) + break; + + encoding_sa = pos->secy->tx_sc.encoding_sa; + phydev_dbg(phydev, "pn_wrapped: TX SC %d, encoding_sa %u\n", + pos->secy_id, encoding_sa); + + sa = nxp_c45_find_sa(&pos->sa_list, TX_SA, encoding_sa); + if (!IS_ERR(sa)) + macsec_pn_wrapped(pos->secy, sa->sa); + else + WARN_ON(1); + + nxp_c45_macsec_write(phydev, MACSEC_EVR, + TX_SC_BIT(pos->secy_id)); + *ret = IRQ_HANDLED; + } while (reg); +} diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index 7ab080ff02df..72d1499e52e4 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* NXP C45 PHY driver - * Copyright (C) 2021 NXP + * Copyright 2021-2023 NXP * Author: Radu Pirea */ @@ -14,9 +14,10 @@ #include #include #include -#include #include +#include "nxp-c45-tja11xx.h" + #define PHY_ID_TJA_1103 0x001BB010 #define PHY_ID_TJA_1120 0x001BB031 @@ -75,9 +76,11 @@ #define PORT_CONTROL_EN BIT(14) #define VEND1_PORT_ABILITIES 0x8046 +#define MACSEC_ABILITY BIT(5) #define PTP_ABILITY BIT(3) #define VEND1_PORT_FUNC_IRQ_EN 0x807A +#define MACSEC_IRQS BIT(5) #define PTP_IRQS BIT(3) #define VEND1_PTP_IRQ_ACK 0x9008 @@ -148,7 +151,6 @@ #define TS_SEC_MASK GENMASK(1, 0) -#define VEND1_PORT_FUNC_ENABLES 0x8048 #define PTP_ENABLE BIT(3) #define PHY_TEST_ENABLE BIT(0) @@ -281,25 +283,6 @@ struct nxp_c45_phy_data { irqreturn_t *irq_status); }; -struct nxp_c45_phy { - const struct nxp_c45_phy_data *phy_data; - struct phy_device *phydev; - struct mii_timestamper mii_ts; - struct ptp_clock *ptp_clock; - struct ptp_clock_info caps; - struct sk_buff_head tx_queue; - struct sk_buff_head rx_queue; - /* used to access the PTP registers atomic */ - struct mutex ptp_lock; - int hwts_tx; - int hwts_rx; - u32 tx_delay; - u32 rx_delay; - struct timespec64 extts_ts; - int extts_index; - bool extts; -}; - static const struct nxp_c45_phy_data *nxp_c45_get_data(struct phy_device *phydev) { @@ -1218,12 +1201,25 @@ static int nxp_c45_start_op(struct phy_device *phydev) static int nxp_c45_config_intr(struct phy_device *phydev) { - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + int ret; + + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + ret = phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, + VEND1_PORT_FUNC_IRQ_EN, MACSEC_IRQS); + if (ret) + return ret; + return phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_PHY_IRQ_EN, PHY_IRQ_LINK_EVENT); - else - return phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, - VEND1_PHY_IRQ_EN, PHY_IRQ_LINK_EVENT); + } + + ret = phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, + VEND1_PORT_FUNC_IRQ_EN, MACSEC_IRQS); + if (ret) + return ret; + + return phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, + VEND1_PHY_IRQ_EN, PHY_IRQ_LINK_EVENT); } static int tja1103_config_intr(struct phy_device *phydev) @@ -1289,6 +1285,7 @@ static irqreturn_t nxp_c45_handle_interrupt(struct phy_device *phydev) } data->nmi_handler(phydev, &ret); + nxp_c45_handle_macsec_interrupt(phydev, &ret); return ret; } @@ -1614,6 +1611,9 @@ static int nxp_c45_config_init(struct phy_device *phydev) nxp_c45_counters_enable(phydev); nxp_c45_ptp_init(phydev); + ret = nxp_c45_macsec_config_init(phydev); + if (ret) + return ret; return nxp_c45_start_op(phydev); } @@ -1629,7 +1629,9 @@ static int nxp_c45_get_features(struct phy_device *phydev) static int nxp_c45_probe(struct phy_device *phydev) { struct nxp_c45_phy *priv; - int ptp_ability; + bool macsec_ability; + int phy_abilities; + bool ptp_ability; int ret = 0; priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); @@ -1645,9 +1647,9 @@ static int nxp_c45_probe(struct phy_device *phydev) mutex_init(&priv->ptp_lock); - ptp_ability = phy_read_mmd(phydev, MDIO_MMD_VEND1, - VEND1_PORT_ABILITIES); - ptp_ability = !!(ptp_ability & PTP_ABILITY); + phy_abilities = phy_read_mmd(phydev, MDIO_MMD_VEND1, + VEND1_PORT_ABILITIES); + ptp_ability = !!(phy_abilities & PTP_ABILITY); if (!ptp_ability) { phydev_dbg(phydev, "the phy does not support PTP"); goto no_ptp_support; @@ -1666,6 +1668,20 @@ static int nxp_c45_probe(struct phy_device *phydev) } no_ptp_support: + macsec_ability = !!(phy_abilities & MACSEC_ABILITY); + if (!macsec_ability) { + phydev_info(phydev, "the phy does not support MACsec\n"); + goto no_macsec_support; + } + + if (IS_ENABLED(CONFIG_MACSEC)) { + ret = nxp_c45_macsec_probe(phydev); + phydev_dbg(phydev, "MACsec support enabled."); + } else { + phydev_dbg(phydev, "MACsec support not enabled even if the phy supports it"); + } + +no_macsec_support: return ret; } @@ -1679,6 +1695,7 @@ static void nxp_c45_remove(struct phy_device *phydev) skb_queue_purge(&priv->tx_queue); skb_queue_purge(&priv->rx_queue); + nxp_c45_macsec_remove(phydev); } static void tja1103_counters_enable(struct phy_device *phydev) diff --git a/drivers/net/phy/nxp-c45-tja11xx.h b/drivers/net/phy/nxp-c45-tja11xx.h new file mode 100644 index 000000000000..f364fca68f0b --- /dev/null +++ b/drivers/net/phy/nxp-c45-tja11xx.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* NXP C45 PHY driver header file + * Copyright 2023 NXP + * Author: Radu Pirea + */ + +#include + +#define VEND1_PORT_FUNC_ENABLES 0x8048 + +struct nxp_c45_macsec; + +struct nxp_c45_phy { + const struct nxp_c45_phy_data *phy_data; + struct phy_device *phydev; + struct mii_timestamper mii_ts; + struct ptp_clock *ptp_clock; + struct ptp_clock_info caps; + struct sk_buff_head tx_queue; + struct sk_buff_head rx_queue; + /* used to access the PTP registers atomic */ + struct mutex ptp_lock; + int hwts_tx; + int hwts_rx; + u32 tx_delay; + u32 rx_delay; + struct timespec64 extts_ts; + int extts_index; + bool extts; + struct nxp_c45_macsec *macsec; +}; + +#if IS_ENABLED(CONFIG_MACSEC) +int nxp_c45_macsec_config_init(struct phy_device *phydev); +int nxp_c45_macsec_probe(struct phy_device *phydev); +void nxp_c45_macsec_remove(struct phy_device *phydev); +void nxp_c45_handle_macsec_interrupt(struct phy_device *phydev, + irqreturn_t *ret); +#else +static inline +int nxp_c45_macsec_config_init(struct phy_device *phydev) +{ + return 0; +} + +static inline +int nxp_c45_macsec_probe(struct phy_device *phydev) +{ + return 0; +} + +static inline +void nxp_c45_macsec_remove(struct phy_device *phydev) +{ +} + +static inline +void nxp_c45_handle_macsec_interrupt(struct phy_device *phydev, + irqreturn_t *ret) +{ +} +#endif From patchwork Thu Sep 28 08:44:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13402294 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CF5E20B04 for ; Thu, 28 Sep 2023 08:48:57 +0000 (UTC) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2040.outbound.protection.outlook.com [40.107.22.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EBBD10C6; Thu, 28 Sep 2023 01:48:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lsay2FTwWLvrnkyqGsgGqH/uwslTJuxOi5oW/FVRg/Lf29XB1fia6CpMfLMwXr9osP1Nd5MJ4uYhB8jWj97j68uTdw/45kreLuz6pvLiq5M/582T976FqNZ1x65Xs6Plod1z5r7/nNFjw28tI5fmhaE15Pqi7lGx7B5kpVBkxSE4beySxmLUzh+YWKp+ACDa3Eej90t/i+IPYlDAjeOLIUGzSLl93MhP6P//ogg4QtmoRG0H4YTgsZCNxwD+bxDenPRjcojZmSXubGeMN1qO5t+xDC1k4SjfdHC0jMAzA7b+yirp0ZWVWtKjCqnMrtIKkNxX//o9mrteHTpePAMPbg== 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=RG6zt1hg40c3g6P6qc28wrj/1Fd65CT+TtzSq6WriZw=; b=g/iGiuQMUm42ukCXprEBARIjE2C/9rIrtX+PCeesDpQzTdN85BFwBMK2Xnw37xdwn8sNjli1PP9feOmVwfL1ZtPqP+pgW33ENUF+9f6l3fjU7hgqvCY6zSJk4va5UADptFIpoyZqaUiPCEjK2KRnKPFJ0wpec6jQ5pL3i3kiKrYD4kbNaOGTkIeQzlPfDN75YM0QJDle0vTK/pKbQC6A3r5W3YmTDYDJPmbyCuvO5ZZ90uMBd9ufn9OgEB1vJS4hhmRRU6Vj3fxDctXF1cWOiQufeXNV1DE1vEJKqyTLJGKCrJ4/v3yWH7AYpRBrfnVbNGJpMp/wmWr8MdJr/BLbAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RG6zt1hg40c3g6P6qc28wrj/1Fd65CT+TtzSq6WriZw=; b=ZfSb6ee7t0rs9DtWnkj6fDe4BIOPJ/EiCowp/EXHlhSsZRf8O1Y60YvSZ+WYSvEzOMk2E5DG2oXqaDbMvPTl2USGwDTC6ZXX5NXL6Lp0q2Y0C2/Ychy8wqj4BztLggdr++dRdG42llH1JibfCEq4YVUnyhuL5PXQasqEArnQLsE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AM7PR04MB7031.eurprd04.prod.outlook.com (2603:10a6:20b:116::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 08:48:50 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617%7]) with mapi id 15.20.6813.027; Thu, 28 Sep 2023 08:48:50 +0000 From: "Radu Pirea (NXP OSS)" To: sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com, hkelam@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, borisp@nvidia.com, saeedm@nvidia.com, leon@kernel.org, sd@queasysnail.net, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, richardcochran@gmail.com, sebastian.tobuschat@oss.nxp.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v6 09/10] net: phy: nxp-c45-tja11xx: add MACsec statistics Date: Thu, 28 Sep 2023 11:44:29 +0300 Message-Id: <20230928084430.1882670-10-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> References: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1P190CA0018.EURP190.PROD.OUTLOOK.COM (2603:10a6:802:2b::31) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AM7PR04MB7031:EE_ X-MS-Office365-Filtering-Correlation-Id: 4733d007-2a0a-4be4-76d8-08dbbfffb2b2 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hsTtcEnGg6jg6HapeYPHBaem312y+0a16ihkty7cl51nYB5IuLgb2FMEUZbcUMrX4Qz2RjZyakxyi//yVpNDNDIcnNNfsFTNHValWvnNrSiDmBaRS9y6VcFCS1vnhoigifDXHojv1hHC029+jbJsua1GKKAQX2K3E4RDU4adNBWDBro2uHLCY+NysLX/xl1CXwjLAxbUdbaTSQL7ANZ85UMhTtquXFK3PaAJ4E4LkXWGdt/+1XDykjM01sUajNEYfaLJ9yfihXZlWMV/zfg6QTlNl5TvmEygFz8icTNBlFfQrz6GVVx4KsZjCnuTTswzUC0iGQkCxDQLQ5n+EImqlyStrDVMZB+cznhaOHRA+4ZvdrVh2urXv93826MLpFf3Akvceb/z2IPPvKZrySAs9AJIJX/mu2Vli7BoD+xp5ZTesBfMLBGdm17d7/VgLRmT76rljcAzFmOneJFNp7e6jIgH2fOyTxUrUg4FCvsZUzucdwNOV7pmXtikv3kX3BA4xP5tR1CEw8QPPwwXx3g+Bvd+/TxTO9/VxxoCGyCx4gm655NPNgfOMLnGtmaSVjdntY+ythHy2k93if3v/qkOJ5q5kh/3MOQ7ht7VFv3uh/d8TYlqt++KBu7ViX+uwvpWXXUEoLUVBG1Nn7mGCvM4Bg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(376002)(396003)(39860400002)(366004)(230922051799003)(64100799003)(1800799009)(186009)(451199024)(2906002)(86362001)(30864003)(38350700002)(38100700002)(5660300002)(6512007)(6506007)(52116002)(6666004)(83380400001)(921005)(6486002)(478600001)(4326008)(8936002)(2616005)(41300700001)(7416002)(1076003)(8676002)(26005)(66476007)(66946007)(316002)(6636002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vAKoQLzICbo/iwWQq+LU+Co7PDMQxGUdqBatNfeXVw2nOIkqwmMMqn8L9MgOwftsqEi+sbVYl2XrZfzlTxqdZTp+Br4LM2iMkvFvRtqa+mVY9oNVK4TR8WVoZ/l9EmJ9x4HpV5l2MqvxZFv04D3wxiq2E8gdVnA2fV2J5lokcB3/M8RUAmaLjFAXgnd8qpGP1cE/dBfZ1q9AAthTnBem3+UssgGBEdZdsvno7o+agFiLsR07vdSIarijN2oYm3bEHMnDqeznBIFrZtA7tbpMwrg94XzouP+9e+lIf4CmJsvdgmA8jBMhakJozINr9qAfERjf7V7gQnAcW+BwbvcCPPS62Ft7A9RPYGSZxsn6DN/32ghGdlUC/NTthSPv6qXWDd2GxkUw7mEt23nLJE+QxehmB2YhrWI0tTwnJIgZYUNu/yrXobx9/zuQ1f4zVSOhXW9UiQg7SSIE9gjfcOQiVNvy2DxZUDMjpTcSC0mKhAVJAH4c+x+vwNKGZue/vC2Qj7dzmrtdnuoqTdxiC+sig7pRpJuRG/4QlQnPjzavO+FI7isfZNBoxyqrr3FrNV19YAp2eJm17TC8vnG+zOxPfTN1i8me4zSHa396B+TjVkHi9dOMWlX2PIpHbJvq8QeaQ2+qVHpJHUzF93QVgLmMsn9SRbYCyp1W9OwH3uMkzht+XnGJTQjBzi9CQK9ZAikIuAUYn/cXELJJYfQPEGZfnPpRrDdH7R2qQwaqQY5wfcCrpnngLyI7nPSJQSr/Pzx1EmaAsfdRU1Z93Gn/25MxfYGVVS4UKjBxe95S7InqYurHmr2QO5m8ZKFECo++TlYg68N0/1EDNM+aOXgrgMCKy4SRz1XnXfGmfPbzyCYEWuYYJiG9zxk9laLQXARC5OSXKL7/z/mULbKEdz36utDGleKm9Jl3noqUAyp7p7ixnLmfkBmmqpbv0wx1eNx12F2hkDIDb65uKyfCAtrxzIdAaz6WBG99l5aXv6Wy6MqVR3z/2l6RJgFkGkukKpbcCY3sxc5zGP16BFrTC9fPlCgtOpJMr869V7pZ94TWersG9ZMud8tPGN9Zgh+J9XtUCjiczPzBzLHLbDECKljtBlnJjVPWpvnWvF6JhEYQgvKtaylrwnM3aZFt6EgicATebukVWiQUCUbmD6JbNAKVTuJVhTbWVBc5H8jUfbA3M9dgLwAFGH+XB9pjJwjEZb5lfkfDeSWkOptO9YJvIAN7b6aafcQCgm7JrbblCJcOXMSHDFwSZ0x4R3smU5MRJZYVXkxdqSpkhB03yaj3J+Mi7wFe9BC/xvl6QGhXoU8C93Z0Zor1/S7SbCDYp3JdLpWm7nMR9XYwqxJZ0cP+gUA3zHqutoquJ2txGn9lRiLGgCr1TIXDKJEMGIcfb7yoKJ5jAJnGFGjpLjHC4lDbud/yU6QtZGhlw3CNqgXdwMGeMk+WKUDix7di3VF0g4eZ8QxSbMzFE4CtLCCQgn3jmcDTEq7DSJ3GWkddnFuRxO9XBHx2XNTpGXicIbwA2oeCO8M/s3ANx6LVJcu8cZocamQBY0gBDMPUDSqPIl/VZKqxC3DuVpU4NP9BSTYnzC8FOVRMwVi6YPnzEECVmHxsXB5PpCGYtQ== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4733d007-2a0a-4be4-76d8-08dbbfffb2b2 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 08:48:33.9880 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Po8Cw7PRb+iLfQCqm6TAL7iDeb1YDMNiziiUWNqLiBNNLomrVjVqw4vvQ/nlLcy1XwWRkghpmm6uGcwK+yxFdDpqvSb9uM56yXgrl1dVFKc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7031 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add MACsec statistics callbacks. The statistic registers must be set to 0 if the SC/SA is deleted to read relevant values next time when the SC/SA is used. Signed-off-by: Radu Pirea (NXP OSS) --- Changes in v6: - none Changes in v5: - none Changes in v4: - Added nxp_c45_macsec_read32_64 function to read 32b counters into u64 variables. - Added nxp_c45_macsec_read64 function to read 64b counters. Changes in v3: - reworked the implementation around struct nxp_c45_sa - changed the way how OutOctetsEncrypted are propagated to the userspace - changed the way how OutOctetsProtected are propagated to the userspace - read and clear OutOctetsProtected Changes in v2: - split the patch from "net: phy: nxp-c45-tja11xx: add MACsec support" drivers/net/phy/nxp-c45-tja11xx-macsec.c | 345 +++++++++++++++++++++++ 1 file changed, 345 insertions(+) diff --git a/drivers/net/phy/nxp-c45-tja11xx-macsec.c b/drivers/net/phy/nxp-c45-tja11xx-macsec.c index 821f8926f7f2..4dd10ea6e06c 100644 --- a/drivers/net/phy/nxp-c45-tja11xx-macsec.c +++ b/drivers/net/phy/nxp-c45-tja11xx-macsec.c @@ -137,6 +137,35 @@ #define ADAPTER_EN BIT(6) #define MACSEC_EN BIT(5) +#define MACSEC_INOV1HS 0x0140 +#define MACSEC_INOV2HS 0x0144 +#define MACSEC_INOD1HS 0x0148 +#define MACSEC_INOD2HS 0x014C +#define MACSEC_RXSCIPUS 0x0150 +#define MACSEC_RXSCIPDS 0x0154 +#define MACSEC_RXSCIPLS 0x0158 +#define MACSEC_RXAN0INUSS 0x0160 +#define MACSEC_RXAN0IPUSS 0x0170 +#define MACSEC_RXSA_A_IPOS 0x0194 +#define MACSEC_RXSA_A_IPIS 0x01B0 +#define MACSEC_RXSA_A_IPNVS 0x01B4 +#define MACSEC_RXSA_B_IPOS 0x01D4 +#define MACSEC_RXSA_B_IPIS 0x01F0 +#define MACSEC_RXSA_B_IPNVS 0x01F4 +#define MACSEC_OPUS 0x021C +#define MACSEC_OPTLS 0x022C +#define MACSEC_OOP1HS 0x0240 +#define MACSEC_OOP2HS 0x0244 +#define MACSEC_OOE1HS 0x0248 +#define MACSEC_OOE2HS 0x024C +#define MACSEC_TXSA_A_OPPS 0x028C +#define MACSEC_TXSA_A_OPES 0x0290 +#define MACSEC_TXSA_B_OPPS 0x02CC +#define MACSEC_TXSA_B_OPES 0x02D0 +#define MACSEC_INPWTS 0x0630 +#define MACSEC_INPBTS 0x0638 +#define MACSEC_IPSNFS 0x063C + enum nxp_c45_sa_type { TX_SA, RX_SA, @@ -175,6 +204,11 @@ struct nxp_c45_sa_regs { u16 ka; u16 ssci; u16 salt; + u16 ipis; + u16 ipnvs; + u16 ipos; + u16 opps; + u16 opes; }; static const struct nxp_c45_sa_regs rx_sa_a_regs = { @@ -186,6 +220,9 @@ static const struct nxp_c45_sa_regs rx_sa_a_regs = { .ka = MACSEC_RXSA_A_KA, .ssci = MACSEC_RXSA_A_SSCI, .salt = MACSEC_RXSA_A_SALT, + .ipis = MACSEC_RXSA_A_IPIS, + .ipnvs = MACSEC_RXSA_A_IPNVS, + .ipos = MACSEC_RXSA_A_IPOS, }; static const struct nxp_c45_sa_regs rx_sa_b_regs = { @@ -197,6 +234,9 @@ static const struct nxp_c45_sa_regs rx_sa_b_regs = { .ka = MACSEC_RXSA_B_KA, .ssci = MACSEC_RXSA_B_SSCI, .salt = MACSEC_RXSA_B_SALT, + .ipis = MACSEC_RXSA_B_IPIS, + .ipnvs = MACSEC_RXSA_B_IPNVS, + .ipos = MACSEC_RXSA_B_IPOS, }; static const struct nxp_c45_sa_regs tx_sa_a_regs = { @@ -206,6 +246,8 @@ static const struct nxp_c45_sa_regs tx_sa_a_regs = { .ka = MACSEC_TXSA_A_KA, .ssci = MACSEC_TXSA_A_SSCI, .salt = MACSEC_TXSA_A_SALT, + .opps = MACSEC_TXSA_A_OPPS, + .opes = MACSEC_TXSA_A_OPES, }; static const struct nxp_c45_sa_regs tx_sa_b_regs = { @@ -215,6 +257,8 @@ static const struct nxp_c45_sa_regs tx_sa_b_regs = { .ka = MACSEC_TXSA_B_KA, .ssci = MACSEC_TXSA_B_SSCI, .salt = MACSEC_TXSA_B_SALT, + .opps = MACSEC_TXSA_B_OPPS, + .opes = MACSEC_TXSA_B_OPES, }; static const @@ -284,6 +328,26 @@ static int nxp_c45_macsec_read(struct phy_device *phydev, u16 addr, u32 *value) return 0; } +static void nxp_c45_macsec_read32_64(struct phy_device *phydev, u16 addr, + u64 *value) +{ + u32 lvalue; + + nxp_c45_macsec_read(phydev, addr, &lvalue); + *value = lvalue; +} + +static void nxp_c45_macsec_read64(struct phy_device *phydev, u16 addr, + u64 *value) +{ + u32 lvalue; + + nxp_c45_macsec_read(phydev, addr, &lvalue); + *value = (u64)lvalue << 32; + nxp_c45_macsec_read(phydev, addr + 4, &lvalue); + *value |= lvalue; +} + static void nxp_c45_secy_irq_en(struct phy_device *phydev, struct nxp_c45_secy *phy_secy, bool en) { @@ -432,6 +496,41 @@ static void nxp_c45_sa_set_key(struct macsec_context *ctx, nxp_c45_macsec_write(phydev, sa_regs->cs, MACSEC_SA_CS_A); } +static void nxp_c45_rx_sa_clear_stats(struct phy_device *phydev, + struct nxp_c45_sa *sa) +{ + nxp_c45_macsec_write(phydev, sa->regs->ipis, 0); + nxp_c45_macsec_write(phydev, sa->regs->ipnvs, 0); + nxp_c45_macsec_write(phydev, sa->regs->ipos, 0); + + nxp_c45_macsec_write(phydev, MACSEC_RXAN0INUSS + sa->an * 4, 0); + nxp_c45_macsec_write(phydev, MACSEC_RXAN0IPUSS + sa->an * 4, 0); +} + +static void nxp_c45_rx_sa_read_stats(struct phy_device *phydev, + struct nxp_c45_sa *sa, + struct macsec_rx_sa_stats *stats) +{ + nxp_c45_macsec_read(phydev, sa->regs->ipis, &stats->InPktsInvalid); + nxp_c45_macsec_read(phydev, sa->regs->ipnvs, &stats->InPktsNotValid); + nxp_c45_macsec_read(phydev, sa->regs->ipos, &stats->InPktsOK); +} + +static void nxp_c45_tx_sa_clear_stats(struct phy_device *phydev, + struct nxp_c45_sa *sa) +{ + nxp_c45_macsec_write(phydev, sa->regs->opps, 0); + nxp_c45_macsec_write(phydev, sa->regs->opes, 0); +} + +static void nxp_c45_tx_sa_read_stats(struct phy_device *phydev, + struct nxp_c45_sa *sa, + struct macsec_tx_sa_stats *stats) +{ + nxp_c45_macsec_read(phydev, sa->regs->opps, &stats->OutPktsProtected); + nxp_c45_macsec_read(phydev, sa->regs->opes, &stats->OutPktsEncrypted); +} + static void nxp_c45_rx_sa_update(struct phy_device *phydev, struct nxp_c45_sa *sa, bool en) { @@ -646,6 +745,23 @@ static void nxp_c45_tx_sc_update(struct phy_device *phydev, nxp_c45_macsec_write(phydev, MACSEC_TXSC_CFG, cfg); } +static void nxp_c45_tx_sc_clear_stats(struct phy_device *phydev, + struct nxp_c45_secy *phy_secy) +{ + struct nxp_c45_sa *pos, *tmp; + + list_for_each_entry_safe(pos, tmp, &phy_secy->sa_list, list) + if (pos->type == TX_SA) + nxp_c45_tx_sa_clear_stats(phydev, pos); + + nxp_c45_macsec_write(phydev, MACSEC_OPUS, 0); + nxp_c45_macsec_write(phydev, MACSEC_OPTLS, 0); + nxp_c45_macsec_write(phydev, MACSEC_OOP1HS, 0); + nxp_c45_macsec_write(phydev, MACSEC_OOP2HS, 0); + nxp_c45_macsec_write(phydev, MACSEC_OOE1HS, 0); + nxp_c45_macsec_write(phydev, MACSEC_OOE2HS, 0); +} + static void nxp_c45_set_rx_sc0_impl(struct phy_device *phydev, bool enable) { @@ -735,6 +851,32 @@ static void nxp_c45_rx_sc_update(struct phy_device *phydev, nxp_c45_macsec_write(phydev, MACSEC_RXSC_CFG, cfg); } +static void nxp_c45_rx_sc_clear_stats(struct phy_device *phydev, + struct nxp_c45_secy *phy_secy) +{ + struct nxp_c45_sa *pos, *tmp; + int i; + + list_for_each_entry_safe(pos, tmp, &phy_secy->sa_list, list) + if (pos->type == RX_SA) + nxp_c45_rx_sa_clear_stats(phydev, pos); + + nxp_c45_macsec_write(phydev, MACSEC_INOD1HS, 0); + nxp_c45_macsec_write(phydev, MACSEC_INOD2HS, 0); + + nxp_c45_macsec_write(phydev, MACSEC_INOV1HS, 0); + nxp_c45_macsec_write(phydev, MACSEC_INOV2HS, 0); + + nxp_c45_macsec_write(phydev, MACSEC_RXSCIPDS, 0); + nxp_c45_macsec_write(phydev, MACSEC_RXSCIPLS, 0); + nxp_c45_macsec_write(phydev, MACSEC_RXSCIPUS, 0); + + for (i = 0; i < MACSEC_NUM_AN; i++) { + nxp_c45_macsec_write(phydev, MACSEC_RXAN0INUSS + i * 4, 0); + nxp_c45_macsec_write(phydev, MACSEC_RXAN0IPUSS + i * 4, 0); + } +} + static void nxp_c45_rx_sc_del(struct phy_device *phydev, struct nxp_c45_secy *phy_secy) { @@ -744,11 +886,20 @@ static void nxp_c45_rx_sc_del(struct phy_device *phydev, nxp_c45_macsec_write(phydev, MACSEC_RPW, 0); nxp_c45_set_sci(phydev, MACSEC_RXSC_SCI_1H, 0); + nxp_c45_rx_sc_clear_stats(phydev, phy_secy); + list_for_each_entry_safe(pos, tmp, &phy_secy->sa_list, list) if (pos->type == RX_SA) nxp_c45_rx_sa_update(phydev, pos, false); } +static void nxp_c45_clear_global_stats(struct phy_device *phydev) +{ + nxp_c45_macsec_write(phydev, MACSEC_INPBTS, 0); + nxp_c45_macsec_write(phydev, MACSEC_INPWTS, 0); + nxp_c45_macsec_write(phydev, MACSEC_IPSNFS, 0); +} + static void nxp_c45_macsec_en(struct phy_device *phydev, bool en) { u32 reg; @@ -939,6 +1090,7 @@ static int nxp_c45_mdo_del_secy(struct macsec_context *ctx) nxp_c45_mdo_dev_stop(ctx); nxp_c45_tx_sa_next(phy_secy, &next_sa, encoding_sa); nxp_c45_tx_sa_update(phydev, &next_sa, false); + nxp_c45_tx_sc_clear_stats(phydev, phy_secy); if (phy_secy->rx_sc) nxp_c45_rx_sc_del(phydev, phy_secy); @@ -949,6 +1101,9 @@ static int nxp_c45_mdo_del_secy(struct macsec_context *ctx) clear_bit(phy_secy->secy_id, priv->macsec->tx_sc_bitmap); nxp_c45_secy_free(phy_secy); + if (list_empty(&priv->macsec->secy_list)) + nxp_c45_clear_global_stats(phydev); + return 0; } @@ -1106,6 +1261,7 @@ static int nxp_c45_mdo_del_rxsa(struct macsec_context *ctx) nxp_c45_select_secy(phydev, phy_secy->secy_id); nxp_c45_rx_sa_update(phydev, sa, false); + nxp_c45_rx_sa_clear_stats(phydev, sa); nxp_c45_sa_free(sa); @@ -1195,12 +1351,196 @@ static int nxp_c45_mdo_del_txsa(struct macsec_context *ctx) nxp_c45_select_secy(phydev, phy_secy->secy_id); if (ctx->secy->tx_sc.encoding_sa == sa->an) nxp_c45_tx_sa_update(phydev, sa, false); + nxp_c45_tx_sa_clear_stats(phydev, sa); nxp_c45_sa_free(sa); return 0; } +static int nxp_c45_mdo_get_dev_stats(struct macsec_context *ctx) +{ + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct macsec_dev_stats *dev_stats; + struct nxp_c45_secy *phy_secy; + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + dev_stats = ctx->stats.dev_stats; + nxp_c45_select_secy(phydev, phy_secy->secy_id); + + nxp_c45_macsec_read32_64(phydev, MACSEC_OPUS, + &dev_stats->OutPktsUntagged); + nxp_c45_macsec_read32_64(phydev, MACSEC_OPTLS, + &dev_stats->OutPktsTooLong); + nxp_c45_macsec_read32_64(phydev, MACSEC_INPBTS, + &dev_stats->InPktsBadTag); + + if (phy_secy->secy->validate_frames == MACSEC_VALIDATE_STRICT) + nxp_c45_macsec_read32_64(phydev, MACSEC_INPWTS, + &dev_stats->InPktsNoTag); + else + nxp_c45_macsec_read32_64(phydev, MACSEC_INPWTS, + &dev_stats->InPktsUntagged); + + if (phy_secy->secy->validate_frames == MACSEC_VALIDATE_STRICT) + nxp_c45_macsec_read32_64(phydev, MACSEC_IPSNFS, + &dev_stats->InPktsNoSCI); + else + nxp_c45_macsec_read32_64(phydev, MACSEC_IPSNFS, + &dev_stats->InPktsUnknownSCI); + + /* Always 0. */ + dev_stats->InPktsOverrun = 0; + + return 0; +} + +static int nxp_c45_mdo_get_tx_sc_stats(struct macsec_context *ctx) +{ + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct macsec_tx_sa_stats tx_sa_stats; + struct macsec_tx_sc_stats *stats; + struct nxp_c45_secy *phy_secy; + struct nxp_c45_sa *pos, *tmp; + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + stats = ctx->stats.tx_sc_stats; + nxp_c45_select_secy(phydev, phy_secy->secy_id); + + nxp_c45_macsec_read64(phydev, MACSEC_OOE1HS, + &stats->OutOctetsEncrypted); + nxp_c45_macsec_read64(phydev, MACSEC_OOP1HS, + &stats->OutOctetsProtected); + list_for_each_entry_safe(pos, tmp, &phy_secy->sa_list, list) { + if (pos->type != TX_SA) + continue; + + memset(&tx_sa_stats, 0, sizeof(tx_sa_stats)); + nxp_c45_tx_sa_read_stats(phydev, pos, &tx_sa_stats); + + stats->OutPktsEncrypted += tx_sa_stats.OutPktsEncrypted; + stats->OutPktsProtected += tx_sa_stats.OutPktsProtected; + } + + return 0; +} + +static int nxp_c45_mdo_get_tx_sa_stats(struct macsec_context *ctx) +{ + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct macsec_tx_sa_stats *stats; + struct nxp_c45_secy *phy_secy; + u8 an = ctx->sa.assoc_num; + struct nxp_c45_sa *sa; + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + sa = nxp_c45_find_sa(&phy_secy->sa_list, TX_SA, an); + if (IS_ERR(sa)) + return PTR_ERR(sa); + + stats = ctx->stats.tx_sa_stats; + nxp_c45_select_secy(phydev, phy_secy->secy_id); + nxp_c45_tx_sa_read_stats(phydev, sa, stats); + + return 0; +} + +static int nxp_c45_mdo_get_rx_sc_stats(struct macsec_context *ctx) +{ + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct macsec_rx_sa_stats rx_sa_stats; + struct macsec_rx_sc_stats *stats; + struct nxp_c45_secy *phy_secy; + struct nxp_c45_sa *pos, *tmp; + u32 reg = 0; + int i; + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + if (phy_secy->rx_sc != ctx->rx_sc) + return -EINVAL; + + stats = ctx->stats.rx_sc_stats; + nxp_c45_select_secy(phydev, phy_secy->secy_id); + + list_for_each_entry_safe(pos, tmp, &phy_secy->sa_list, list) { + if (pos->type != RX_SA) + continue; + + memset(&rx_sa_stats, 0, sizeof(rx_sa_stats)); + nxp_c45_rx_sa_read_stats(phydev, pos, &rx_sa_stats); + + stats->InPktsInvalid += rx_sa_stats.InPktsInvalid; + stats->InPktsNotValid += rx_sa_stats.InPktsNotValid; + stats->InPktsOK += rx_sa_stats.InPktsOK; + } + + for (i = 0; i < MACSEC_NUM_AN; i++) { + nxp_c45_macsec_read(phydev, MACSEC_RXAN0INUSS + i * 4, ®); + stats->InPktsNotUsingSA += reg; + nxp_c45_macsec_read(phydev, MACSEC_RXAN0IPUSS + i * 4, ®); + stats->InPktsUnusedSA += reg; + } + + nxp_c45_macsec_read64(phydev, MACSEC_INOD1HS, + &stats->InOctetsDecrypted); + nxp_c45_macsec_read64(phydev, MACSEC_INOV1HS, + &stats->InOctetsValidated); + + nxp_c45_macsec_read32_64(phydev, MACSEC_RXSCIPDS, + &stats->InPktsDelayed); + nxp_c45_macsec_read32_64(phydev, MACSEC_RXSCIPLS, + &stats->InPktsLate); + nxp_c45_macsec_read32_64(phydev, MACSEC_RXSCIPUS, + &stats->InPktsUnchecked); + + return 0; +} + +static int nxp_c45_mdo_get_rx_sa_stats(struct macsec_context *ctx) +{ + struct phy_device *phydev = ctx->phydev; + struct nxp_c45_phy *priv = phydev->priv; + struct macsec_rx_sa_stats *stats; + struct nxp_c45_secy *phy_secy; + u8 an = ctx->sa.assoc_num; + struct nxp_c45_sa *sa; + + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci); + if (IS_ERR(phy_secy)) + return PTR_ERR(phy_secy); + + sa = nxp_c45_find_sa(&phy_secy->sa_list, RX_SA, an); + if (IS_ERR(sa)) + return PTR_ERR(sa); + + stats = ctx->stats.rx_sa_stats; + nxp_c45_select_secy(phydev, phy_secy->secy_id); + + nxp_c45_rx_sa_read_stats(phydev, sa, stats); + nxp_c45_macsec_read(phydev, MACSEC_RXAN0INUSS + an * 4, + &stats->InPktsNotUsingSA); + nxp_c45_macsec_read(phydev, MACSEC_RXAN0IPUSS + an * 4, + &stats->InPktsUnusedSA); + + return 0; +} + static const struct macsec_ops nxp_c45_macsec_ops = { .mdo_dev_open = nxp_c45_mdo_dev_open, .mdo_dev_stop = nxp_c45_mdo_dev_stop, @@ -1216,6 +1556,11 @@ static const struct macsec_ops nxp_c45_macsec_ops = { .mdo_add_txsa = nxp_c45_mdo_add_txsa, .mdo_upd_txsa = nxp_c45_mdo_upd_txsa, .mdo_del_txsa = nxp_c45_mdo_del_txsa, + .mdo_get_dev_stats = nxp_c45_mdo_get_dev_stats, + .mdo_get_tx_sc_stats = nxp_c45_mdo_get_tx_sc_stats, + .mdo_get_tx_sa_stats = nxp_c45_mdo_get_tx_sa_stats, + .mdo_get_rx_sc_stats = nxp_c45_mdo_get_rx_sc_stats, + .mdo_get_rx_sa_stats = nxp_c45_mdo_get_rx_sa_stats, }; int nxp_c45_macsec_config_init(struct phy_device *phydev) From patchwork Thu Sep 28 08:44:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13402295 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DF5920B04 for ; Thu, 28 Sep 2023 08:49:24 +0000 (UTC) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2048.outbound.protection.outlook.com [40.107.22.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20ABF1BC; Thu, 28 Sep 2023 01:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bJbhWOGVJG1EjH05UlS/4y7yHFdp3iduXPW5t7Foz+bZLzS73qTAqT/hTAamm+iCzmoQL02DwRIB8W1cn48BZ0vWjCoq1L0t6o8dtfV8SD9hUMOhnqYywSt8j9HD4PzA/LcY54eXwCDg6R5DiEZJd1iV6Tmr2JYneJlM+jtfRRZYpu2tD5Xl/zFzenvTY7asGVx41yUZfQEL25NDJIs2SfrXwA1XX2fpg4dDicR9FEKvRAfbcqRDMG4zYJYbKdL3VxQELWlpnrWS0W4GlkyJE67uu/zmTxLKy8JbHDTQK5ffFzE4x4T/Ku1nVsoriD7DkD+LMJfs5E4nZe/Izt37jg== 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=aDxW+HlF2eiHptX3MwB7502MMG86U1ZOVM6PfRMsk60=; b=fqI/ZB9AKJdDzTrcgW+igdDfgQmCpZidnpji2GkLVReOwLpzruKPEbpn0I9RRjuuEPRk7YiGEPphhe4zjYDs05dQCzGpe+f54iLNQhIoFSz6VUKvsiA063nT8DhgVs8uFWqv/x+mNvKTcsNI4GxKEBlaPNGUwV3jQjeX3ucDxso37XZyCtUPbKeHVkmNcMUiHdPS/2ry5xAnfyeWhIQJJN2NZhBIWdZM55MJJ2bhwqYZ/ZS9ZqiCdc3Q157ot2TrH3N/Lvf9EhYYGlPtoE4k2lEwaC/AvB3+F745mvNqtDwMX/9zsmOK8ORQwSaJE9UxMIvYX0zSY7hzClsBJo43hA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aDxW+HlF2eiHptX3MwB7502MMG86U1ZOVM6PfRMsk60=; b=BHq0dJm/0/vUPaMwCzoO38YoaTGpsGFyy3aZMlYEGLkhRcFadxP6rRNLYbydveOrD+SPYXM9VAeAiqWmBEodq3BSxk4yn7r47YVh4MmWrR1hErQnBBFK3lhUSg7QLCjgIt4s//RFj0lw1nUfFpirLFE5d1kUZuttuzru8r9X8WQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AS8PR04MB7861.eurprd04.prod.outlook.com (2603:10a6:20b:2a9::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 08:49:15 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::e109:7026:7d76:5617%7]) with mapi id 15.20.6813.027; Thu, 28 Sep 2023 08:49:15 +0000 From: "Radu Pirea (NXP OSS)" To: sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com, hkelam@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, borisp@nvidia.com, saeedm@nvidia.com, leon@kernel.org, sd@queasysnail.net, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, richardcochran@gmail.com, sebastian.tobuschat@oss.nxp.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v6 10/10] net: phy: nxp-c45-tja11xx: implement mdo_insert_tx_tag Date: Thu, 28 Sep 2023 11:44:30 +0300 Message-Id: <20230928084430.1882670-11-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> References: <20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1P190CA0018.EURP190.PROD.OUTLOOK.COM (2603:10a6:802:2b::31) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AS8PR04MB7861:EE_ X-MS-Office365-Filtering-Correlation-Id: ec3201b9-bdbf-4374-c870-08dbbfffbd67 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9dHK/GO2waIk3pFLLIWv6JjCOuCAt6J+TJ7wr+uPgtMju1WqtOHQn1q9OcDptUYfIekrwgTlLQUw7HRcJj7EFx01I9fQuuh8SlpnQJxNyGRVLWrUQITnp6XdtxEuLSWwPO/piM6bLwpDop8o51+K3P5IjbQ5tGOiHFKQ/uafVoxndVzZdLtv8ykf8mY93LU6v3uARmaXMgQf3PzqQ9vOs/jzPq1uVvqtdCl26VMIrl2ZYXi0JpYJZTEM27IyI7kum2L/Q7caGmgAevXF+n2hdBsUxtTzryCnTa6FTvyUYSxfHPY3ul4qHU91PbcYJ0b1OjYO1PEV84YBpzERaDMVb5iuBCDp712yVOvfmvgARorblbm11xCI2KY0i/vf3kxxSr6SW9wE12RRSQWDrHPBlXkA3FXWDH7jiNPjz6/9cR4kMVESrWwBPmqb21WX1WryIAGphdSWyvfdobFEY++Dzemf7yZi/PvXXK1TjoIl/gXHsydoRJ+j/DP3RGaJn6KSBmMPFmidQ5WbTfDsLeFwhUPFgBNDqlOO3A9EpGty7ZG/eGRv9zLSRPsatP9zxdiZCau5Co+1hh6mUczwGcQvdzk1vmYu3qr/lwc3Cz3SuoWG3hCjLZs6+U8MrsaB7wlJztjmasP1ixjJ10BElSLKhA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(366004)(396003)(346002)(376002)(39860400002)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(6506007)(26005)(66476007)(66556008)(6666004)(86362001)(52116002)(1076003)(6512007)(6486002)(478600001)(2906002)(38350700002)(38100700002)(7416002)(316002)(8936002)(5660300002)(4326008)(2616005)(66946007)(8676002)(921005)(6636002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4fYMPIjD2GBNBFd11Fp1Vi+sncZ+zTBkFmSD2dkwPcjjyELEY2gqHcPXAuVKFggSd8vJZe+AnrB+ppdnls6LNGM8ld3WqjnUrlbqFtGl7XnR7iSo7XzntEIpRYT69ky0bYoyY7OavPy5WEiiD1zsNmJOxxqvaFoAwWindqLntgB5rLOuK3ptg1G8oOdph28YUMNw6BvrSK4h2FoYwiA0P4Ra9/NoNGTLETLhA4fO9UV+zzI+MnOz1/CyTclQUvGFNZ41cjyodzfJB1KpC0/6yt4UZgL6To8T/LF0qsrFSUXzOlEOkBACFLB8p5+33GknmSY3jWHw32LA1A5akimYvOayntDHg5Gh1T8GfRLK/D8PeL2gI7zTkToAj+9+1q8SX+PYBZRQ5w0dUbQfZf5u2gC8fb8b19YPb/P91ISsgarRkzIjGyG6ucshqqnJzsKYCJVZoqZOKDGlpv2nPnoSRKXt6tWDTC7uKm8AQoZme6xCS/HZnjcPRuZ3ts+eZ10pqz3fplSIl205JhRWVSy3V4rWnh78Yq4pNGDUBmNwU75IwY7F3KfBBKr8s5HsZwxBz4YNxmyYRgK3J5Kx3TsKM/w4HJGpgTpLJgKL8sQoC2qxFiYr/n0+cSxvtWRqZSpuVOtJcTd/w+Ms0dwrMbBt30JR49V7hDwsnRrjaboqSlvemYEWYGBM0AYoO/GudKw33FqOb2lRvRJvhFU9ykU81TD8Q8+CVkCawrBPfT8BlyNuEgaM7wUNVPAeuPuxCd9Y02sgcIByyeWx9JeyhhZiY7uYvLdID4ZWVris67ndsizysO7CjzJRUNDglg5xpiPsSn5+SPNdlltxLDUojT9EWDXljh1IqsF5PiQBGDMMhD8PtTrDZU6YJ3lQYh/YYnhrXdGOPW3ufhr2fj6wWZ+31kODmIvweJc8EhWxAa1bSxnWB6L+DgKBxJBqW6YYJOeqM2nlJf56WHR2nn54bMBcdsSCvwUis6bnZ9EHe4lqjYBH5ExuhJHORWHiM4HeFsBAp1UD6RmcUdufTzPTb2uEExAluybuUiBMCK+yOq2ZngpLWmiOogg7m3RHxyeIBq/FiOX8TROsCTD/y1O+VV86LOiqrdqto3IpYCUSXsApOke2egsQe8UGi2K3N0ddNU0v64ZGHP4Zjume8TLuuD099Ko4bBmIjGzwwSRS5pFjRW0x8t9kp6+P4afLPwi2EIR28y7mGyRNkfBi0ORCR3unp6ZOKQ0GnV68kAA0avw5pF1pSypKkL0gQovO+zIb7YecDhlvpU0j/j0/rsPegWGv2xrN1qhElWv2BkEGj5Bx7q+S4sYR39oWjOUAL9LyIJl6q3BIdB57pjwpVHiWC3qXH3i/W1CMe4cuz3gKMiB/Pt57sVMWsb4c7mH0KY0crH/gre17gT4JsvY1B7KQPdodRwH/bDVxcn+c+Ly9h92y3wMAPIyJ4xD+b5tV146ke8i4riCRkisIGzuaeKsXu5nG8uMRFNfIGHdJM1U3ly4ABRqM0TFTvXIwgJI5/vD69UMez8K1hNC6UEhE+WT3icKgbj0By4jGgpT7M2WH5o5DxJE92e1KBnUI3fqPjIi0oiBFA49QuoGNJECIQLabC0MDLQ== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec3201b9-bdbf-4374-c870-08dbbfffbd67 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 08:48:51.9420 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5bKUaHJJLjOr4bcnEwBrjINnXm6Y6Bbzdw8Lb+2ghrXEu4FeOtFAJLHs2uT1NfZ2EqBciJ/TZ4Md9YvjshdVFs5SlsIVo18nePgn+hV92QA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7861 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Implement mdo_insert_tx_tag to insert the TLV header in the ethernet frame. Signed-off-by: Radu Pirea (NXP OSS) --- Changes in v6: - none Changes in V5: - removed unused defines MACSEC_TLV_CP and MACSEC_TLV_SC_ID_OFF Changes in V4: - removed macsec_extscs parameter Changes in V3: - extscs parameter renamed to macsec_extscs and improved description Changes in V2: - added extscs parameter to choose the TX SC selection mechanism between and MAC SA based selection and TLV header based selection drivers/net/phy/nxp-c45-tja11xx-macsec.c | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/net/phy/nxp-c45-tja11xx-macsec.c b/drivers/net/phy/nxp-c45-tja11xx-macsec.c index 4dd10ea6e06c..6ff0ceeeecd1 100644 --- a/drivers/net/phy/nxp-c45-tja11xx-macsec.c +++ b/drivers/net/phy/nxp-c45-tja11xx-macsec.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "nxp-c45-tja11xx.h" @@ -118,6 +119,8 @@ #define ADPTR_CNTRL 0x0F00 #define ADPTR_CNTRL_CONFIG_EN BIT(14) #define ADPTR_CNTRL_ADPTR_EN BIT(12) +#define ADPTR_TX_TAG_CNTRL 0x0F0C +#define ADPTR_TX_TAG_CNTRL_ENA BIT(31) #define TX_SC_FLT_BASE 0x800 #define TX_SC_FLT_SIZE 0x10 @@ -166,6 +169,11 @@ #define MACSEC_INPBTS 0x0638 #define MACSEC_IPSNFS 0x063C +#define TJA11XX_TLV_TX_NEEDED_HEADROOM (32) +#define TJA11XX_TLV_NEEDED_TAILROOM (0) + +#define ETH_P_TJA11XX_TLV (0x4e58) + enum nxp_c45_sa_type { TX_SA, RX_SA, @@ -1541,6 +1549,31 @@ static int nxp_c45_mdo_get_rx_sa_stats(struct macsec_context *ctx) return 0; } +struct tja11xx_tlv_header { + struct ethhdr eth; + u8 subtype; + u8 len; + u8 payload[28]; +}; + +static int nxp_c45_mdo_insert_tx_tag(struct phy_device *phydev, + struct sk_buff *skb) +{ + struct tja11xx_tlv_header *tlv; + struct ethhdr *eth; + + eth = eth_hdr(skb); + tlv = skb_push(skb, TJA11XX_TLV_TX_NEEDED_HEADROOM); + memmove(tlv, eth, sizeof(*eth)); + skb_reset_mac_header(skb); + tlv->eth.h_proto = htons(ETH_P_TJA11XX_TLV); + tlv->subtype = 1; + tlv->len = sizeof(tlv->payload); + memset(tlv->payload, 0, sizeof(tlv->payload)); + + return 0; +} + static const struct macsec_ops nxp_c45_macsec_ops = { .mdo_dev_open = nxp_c45_mdo_dev_open, .mdo_dev_stop = nxp_c45_mdo_dev_stop, @@ -1561,6 +1594,9 @@ static const struct macsec_ops nxp_c45_macsec_ops = { .mdo_get_tx_sa_stats = nxp_c45_mdo_get_tx_sa_stats, .mdo_get_rx_sc_stats = nxp_c45_mdo_get_rx_sc_stats, .mdo_get_rx_sa_stats = nxp_c45_mdo_get_rx_sa_stats, + .mdo_insert_tx_tag = nxp_c45_mdo_insert_tx_tag, + .needed_headroom = TJA11XX_TLV_TX_NEEDED_HEADROOM, + .needed_tailroom = TJA11XX_TLV_NEEDED_TAILROOM, }; int nxp_c45_macsec_config_init(struct phy_device *phydev) @@ -1581,6 +1617,11 @@ int nxp_c45_macsec_config_init(struct phy_device *phydev) if (ret) return ret; + ret = nxp_c45_macsec_write(phydev, ADPTR_TX_TAG_CNTRL, + ADPTR_TX_TAG_CNTRL_ENA); + if (ret) + return ret; + ret = nxp_c45_macsec_write(phydev, ADPTR_CNTRL, ADPTR_CNTRL_ADPTR_EN); if (ret) return ret;