From nobody Tue Dec 16 07:31:10 2025 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2068.outbound.protection.outlook.com [40.107.247.68]) (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 97BA64B1E48; Thu, 8 May 2025 09:52:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746697981; cv=fail; b=Hsmfe6JAudNoFaSRr9DNIbcvNEdJpfrQHhdF0Pe1bnGNhHbDTHgaB0oqXga/fONYuaAE8wH9glLXIOa8GzxMsOiYwNGmQKeRk8flKYeo8p8d4Z3DXsxDzD6TCcT8xkz06kc+MgnxT8sLg8y2EPuNwIH/VijBknclVSNQO9zJ7ls= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746697981; c=relaxed/simple; bh=ao5cvOnwTetk9fRyzyOBNsgf2mg+bb60hyiAzyj078Q=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=UG/VDVfAq1+9WdfsBgxGrjuNJDOATJjTQQlnCN5d/b0TKhQj03qv7sYmPGSPGg0kYK+ps47wHF3KFe8LHQo4ffujSbtSrh3WCBUDMg5UJKetRIgsyBOmkRklK4wZ2GFVynDyXryzCsfZNiCbC3Ay4d7Vq782Qy+6dAEVCkhcPkU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=LgPZCNMK; arc=fail smtp.client-ip=40.107.247.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="LgPZCNMK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Dsv/TreZZGuOi3+dqANubq88YzufekjQB0w6v2ARVF6OWgdeuOUVvoobs54pcr5EiiN+jJODvTERjpc0/4wcG+OTy1kUvtdax0oeEDp+yrIYvokcmNF7Ys5gBq2rM1R/MCDq31j06ndAtILQIBrRibjYVwpYGXOpvyosjyQfBO2z/JHUwYdaF2xMDP+kSgSH2bvJnzIJrjvM5AFHdL935mh7TLRZRDWuug8Jsq+ELPMgNLrvHKDHwj11q/N+Rbm1/JOJI4IffemLgG6kODBFeD36vRtehNuwr1PHuA6gNUzu4V9z3Nctf9cSm7mWSi/+nvu3dAt4POK/2ilBVKnd7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=wgAgz13nr1UeQxxn2/oTbRdWsysuey0u7OLUf/xTxfc=; b=yWYktPYjnVump6SvpMIYDLOLwnlUi191qvp5xrOV39Pc3RHqh6J5gyvuueHLFbTu/HvUW6zEW6geqr6bVZdQT+MhkmeSau5ME5s0ouQwPaD0/05zuQ0GJMiRHL7tHTUefXr2vUu1OgtORaRAzIQMRINlNbyhpJ61HNFbmlcWsrbbGS376i5vwOelckozT1d7aVkw8yIZUbd9waB58MdaX6/PbBioMpsfZQpwVQoYP0U5hOAybOxkwJMZLjOtVMCM2zMrwLeILcMHafbrjDaUg/lb4mwdAZhaJMZ0lwqh/Voeh1i41QeP1Xu6N0/kqZ9Yk9A7KrIjMGBytE1wUyqadw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wgAgz13nr1UeQxxn2/oTbRdWsysuey0u7OLUf/xTxfc=; b=LgPZCNMKDNwEpwYb3lGzsgEMx0br+XzPDtukouLdyTyUVTdfexCSRgHOjHaPgeI8+nRMS+svyIqXe1UGy3sRaKVW3h49qns4PqDF4MsfqBhmrNTn0jMRJ5YwMkclIWBMLTDoybxD7EbAK5cAaRLmMyHhTD57SxXkbkJ/odDYN8OlXZe9HNVQMpTSjcP181XEExaqUId60cIC9JToFM1tD+bU0ngQ89b8oq/KRylYksQOHiLh8irm3ap5EpoO2ddqZluCMc48YwWYJZaGf1OvA0zPN+Lv0euy3wy/4KvkBzsGG7Fw0LRUKcelQu/mNt3AaL9tldlaNzde7GZRzXmePQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) by DUZPR04MB9947.eurprd04.prod.outlook.com (2603:10a6:10:4d9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8699.24; Thu, 8 May 2025 09:52:52 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%4]) with mapi id 15.20.8722.020; Thu, 8 May 2025 09:52:52 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: =?UTF-8?q?K=C3=B6ry=20Maincent?= , Kurt Kanzenbach , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Woojung Huh , UNGLinuxDriver@microchip.com, Claudiu Manoil , Alexandre Belloni , Simon Horman , Richard Cochran , Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next] net: dsa: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set() Date: Thu, 8 May 2025 12:52:36 +0300 Message-ID: <20250508095236.887789-1-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.43.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: VE1PR03CA0044.eurprd03.prod.outlook.com (2603:10a6:803:118::33) To AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM8PR04MB7779:EE_|DUZPR04MB9947:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b3ed512-d557-4208-794e-08dd8e16194e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|7416014|52116014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?dk5AhT34AOfQJHv4ZFAIWdLurPCB4DoSkCO3HzQGchcUIR73bpA5Fw2Vt4of?= =?us-ascii?Q?0lro8ujWvF9107X03ap0+Jm3pon5kH3kZiFF8Qoly2agCXQhDHJHvJAo1e+f?= =?us-ascii?Q?9P77VJJZS4k1VroykUFzvS/usJJwoUd2T07+/vbVW3I6HRAmFIPS/bcKJCl2?= =?us-ascii?Q?8RAnXBhfhmxNAx4TUPvTJkKSMAQ0d+lcrko3d2/m19gRIDxEYxXaRXxnTinH?= =?us-ascii?Q?D2DFWxPjzlGzbjK7jgP2Mt/qZDxCAxmUT91MK8cYO1+F2BDv4XLOi4+oWr0w?= =?us-ascii?Q?Fvj7w1nQCRifTZJZ5eq6fKy0S3nFZBcE3IIcra1Ltzyl0op99xvZwOQ7YA0A?= =?us-ascii?Q?/tK9dAEsO9UVBAXK3EgGk6Myhl7/MtfNCrlSq+IeNLic6HsPwZTKNiA/0+X9?= =?us-ascii?Q?NwBLpxFZ6tEHaNdxFivP4cuU8z3RrXHsLbI5P8wz7pAQqVWBXrfM09FC57vL?= =?us-ascii?Q?gaVOD3AJ1OJzFs5Nhsb9Zh+snbhV78xvxLE7nQ7HVfeUQB1uVP+w0sPgyf+D?= =?us-ascii?Q?9KqjCGXl/wq9uEwmkawzdKcgwHJgFCfy75CNdnZdPNCnhR+7kWy54PkmAPDD?= =?us-ascii?Q?r5oCQt83lJpcvo6Y6R2ptvds6V80lrskK4E9Wv6QjKCHgZIcE84AampoWSPX?= =?us-ascii?Q?TGniUTuNFsQe+ofOqsVc6ORX6cUDN4nt3pAZiuJ8zKTjw3AfpeODUevMJFU+?= =?us-ascii?Q?cYqsPLCFnH6YKEYstwvXmA1adk7OofbOqttgkARhKXvV0Yyx+vo2yyIXAQZK?= =?us-ascii?Q?/0UHPfeztETcJp2LyI6VpuomqAlEe4m9u56i/LwnAvfB11ccgaqMD/dwHUCy?= =?us-ascii?Q?9HCfh9+LaWb1JnKxeiwkgxkfwrNtggungHrhze7DZL38o26iQAdf2E2QBtSJ?= =?us-ascii?Q?jrQUrhpKr113oUryyu9clIboHBMKK63yAm/RBjsWAzI35SkbOQLUL3vfAoK9?= =?us-ascii?Q?RU5gOL2Afp8AAXMtsG97i/WVo0PzcrWy9V7rxCISa2c+7FaHLoBKy9iNB1U9?= =?us-ascii?Q?Q9hEeyNDQLHou2SToWta36Zk1DZmhZiujjxoiKx33PRBVGPr4oTxTEHiThxI?= =?us-ascii?Q?9NtlRTEgITEvCT3i6Ld7qmf5+S4O8Z45r1VsBuufa8vMPSPf7lWxpLrIexCs?= =?us-ascii?Q?Lpr/8nhAzIGZJehz4z/vvVbsUhw00ZhPEcWAm6x2xWWFSjcwCBmIoQNM7imN?= =?us-ascii?Q?koLQ/BtDez+CWvU49PzkKbb26b2sQNUgRSNk5B5Nv0D8MVDr8ub8UF70GQLu?= =?us-ascii?Q?yzKbCBCSGuQ2IZNmkRoNqYB1YTuH7vyYdmnFhuNZMgINjS53TGOEfw8jo9Xc?= =?us-ascii?Q?23qaaN73K6DGtEtPgj/uxvnFCu+zWevXpcM0IDpm6dIONKru+sWl1gmPggMu?= =?us-ascii?Q?bKEL6g9+8B+HdF43e0iNUktrRgNDd7Ot1BIOHA8vjdkw7Jo+pdq3ES3QfYMn?= =?us-ascii?Q?lYoFGZqmN+k3inGrvDHi03g6TV/dFbENyxXK57SGD7zYA6rjw+oDKg=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM8PR04MB7779.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(7416014)(52116014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?8DvyFwCSmMEB8yEvht9NhxmPmQfS+KTIrxusJnGgq77jmJoObcjWirKIzAl2?= =?us-ascii?Q?mbyfgsklVjn4t/YgIAiARVjBy2+rFTP2W8Q8RfwDazqVgA3vgmK4QTqaq/tA?= =?us-ascii?Q?p8JxpKpI7sxHl9k2D3xtWiVg3nn2NKXm9DtL2aNJSCy4GAl0QKXIzEfs0ppU?= =?us-ascii?Q?sCn8HsUOst+YOhIgy1Ct1dB5056heu78GGdU0W45pyuT+E7nIAoM17K6Mzye?= =?us-ascii?Q?cLmliNztX7ZTPoQPNQcdxaBRZikg7iDR/cFfDVd4ZeGbl0+xJnU2BL80sueY?= =?us-ascii?Q?rI3+via3deaQ5WAsQZEx7Kg/vs7kssd8dfmSreyRVGI3MnpITfhIiqiouRbe?= =?us-ascii?Q?HQnRcUaqYjvjrSGszCWKzDYm8kjfNkxhQM/KG7t888iqptRZMkFbBDr4vP5W?= =?us-ascii?Q?mr1hEFs1aBAX2otekeL/QB4ZbLGOIs7pwR+StR7Q0z2MIuX83WMLXO/lkskT?= =?us-ascii?Q?wEdFbj4/kSNgFznna7mAPQsF5PvsHqxa6Whxoza3KCZoNr5xCbKVq7FG2n+w?= =?us-ascii?Q?Yyl3+27QCiBIu97MFow0lBQvRD3H0GIHMqQQrmZrjuPD3fhbpwGfcGUEaWWa?= =?us-ascii?Q?9r0pGgAW6386SaGhmYx8z7PfMGfDKplMNtnMxyM1V286vBAtyL3CPQD7UXkx?= =?us-ascii?Q?AvuYyWsU6MqZGYw132T8gm7ueNsOnk5uhDgTYVqzwYNpDoYA3+F6sHMe15H4?= =?us-ascii?Q?lKWiwRe9IFgjQmn70e+4YTv3ImLXI87tO7kyudkAVnYQ95Gp5/Ip0M9ItSE9?= =?us-ascii?Q?mLW4nVjhUDZVovMvC80WzeMVd+ppMA1ITfLk8B1lGTeMGztQd/8D/ysDFFbP?= =?us-ascii?Q?DIHq3ejGk6lwi2eWrKiZH3pkd1wNJafyYbis7rZsYP26pZQJwvbiTtMmAYq7?= =?us-ascii?Q?93ABgQEsIBGzgrl83sVvUSjasSc9CQDvZKwotnW5FDv+klHZsIgCPqXgb1yr?= =?us-ascii?Q?IiUB8sMg9rRRwIzNOqMIx8qwZI9bPGRBiSTDsf9zULYPRwfMxeRExzOI52Yh?= =?us-ascii?Q?mCCO8yd4+Alg3/nFikRauBAUl3m0i2ZnMoCCN9dwNiePjJrmjt9hyYonAVak?= =?us-ascii?Q?6T+PAYtNz19rLWxgYCj70Js5LmbsG3a1pv0V/7b2WMlPAgeWK8JZScmJz2XO?= =?us-ascii?Q?tSPVTotc8nnUO78WWCh0NPTJBmmzmKrtjTzNtDKOljiUo60wfV1EY/4MPRoi?= =?us-ascii?Q?OfS/VZ+T8xiEUGsXWdSd2uV/6ww/o5v2e8SBkUemTi3PRa3uTk4/jwzkWqGD?= =?us-ascii?Q?+Vd2+XiwEqmCv9JxRFOwdkrzH/p2vfsE3oF4J4ioGKvXxwJOTYVF+wVPNJtY?= =?us-ascii?Q?DE2ur/LT61PzpqVYLp6GNzHmrnANRkHo5GGeAhIg9OL2P8YN2U4cBIl4CU/u?= =?us-ascii?Q?juiiHf97gwmjgHTZWLo3PcM5+tJs/1kPgIiwmx8rtf+03u1/FcCRX7zwsd1a?= =?us-ascii?Q?NxwjcXiiM8Ph1DiBMJKuAvSiaoH+eKLjQv7OnPPp4VKU6CANWm4i7+Qw5gA4?= =?us-ascii?Q?OoS/Jm7+0vUMt3Hl2nz4BdXJ4n48SVlYcgOnU4SePGE6VS30n0cFSume0Nb2?= =?us-ascii?Q?JhaMcGQRoB6JMGxG5Yyj+9xdrvl91lNHN7sIbGnbTipavhNMsEjv86FXupUI?= =?us-ascii?Q?/Q=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b3ed512-d557-4208-794e-08dd8e16194e X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2025 09:52:52.5876 (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: 7uh0ioVsDBbRLJwYxt9eSemEKvuvJHtIatWWCo2vHP+GHj02sVLCd7FB6N48RhausoC+Hiv9gMsh7KV26uzbbQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DUZPR04MB9947 Content-Type: text/plain; charset="utf-8" New timestamping API was introduced in commit 66f7223039c0 ("net: add NDOs for configuring hardware timestamping") from kernel v6.6. It is time to convert DSA to the new API, so that the ndo_eth_ioctl() path can be removed completely. Move the ds->ops->port_hwtstamp_get() and ds->ops->port_hwtstamp_set() calls from dsa_user_ioctl() to dsa_user_hwtstamp_get() and dsa_user_hwtstamp_set(). Due to the fact that the underlying ifreq type changes to kernel_hwtstamp_config, the drivers and the Ocelot switchdev front-end, all hooked up directly or indirectly, must also be converted all at once. The conversion also updates the comment from dsa_port_supports_hwtstamp(), which is no longer true because kernel_hwtstamp_config is kernel memory and does not need copy_to_user(). I've deliberated whether it is necessary to also update "err !=3D -EOPNOTSUPP" to a more general "!err", but all drivers now either return 0 or -EOPNOTSUPP. The existing logic from the ocelot_ioctl() function, to avoid configuring timestamping if the PHY supports the operation, is obsoleted by more advanced core logic in dev_set_hwtstamp_phylib(). This is only a partial preparation for proper PHY timestamping support. None of these switch driver currently sets up PTP traps for PHY timestamping, so setting dev->see_all_hwtstamp_requests is not yet necessary and the conversion is relatively trivial. Signed-off-by: Vladimir Oltean Tested-by: Vladimir Oltean # felix, sja1105, mv88= e6xxx Reviewed-by: Vadim Fedorenko --- drivers/net/dsa/hirschmann/hellcreek.h | 2 +- .../net/dsa/hirschmann/hellcreek_hwtstamp.c | 24 ++++------- .../net/dsa/hirschmann/hellcreek_hwtstamp.h | 5 ++- drivers/net/dsa/microchip/ksz_common.h | 2 +- drivers/net/dsa/microchip/ksz_ptp.c | 26 +++++------ drivers/net/dsa/microchip/ksz_ptp.h | 7 ++- drivers/net/dsa/mv88e6xxx/chip.h | 2 +- drivers/net/dsa/mv88e6xxx/hwtstamp.c | 24 +++++------ drivers/net/dsa/mv88e6xxx/hwtstamp.h | 16 ++++--- drivers/net/dsa/ocelot/felix.c | 11 +++-- drivers/net/dsa/sja1105/sja1105_ptp.c | 32 ++++++-------- drivers/net/dsa/sja1105/sja1105_ptp.h | 7 ++- drivers/net/ethernet/mscc/ocelot_net.c | 33 ++++++++------ drivers/net/ethernet/mscc/ocelot_ptp.c | 43 ++++++------------- include/net/dsa.h | 5 ++- include/soc/mscc/ocelot.h | 7 ++- net/dsa/port.c | 10 ++--- net/dsa/user.c | 41 ++++++++++++------ 18 files changed, 147 insertions(+), 150 deletions(-) diff --git a/drivers/net/dsa/hirschmann/hellcreek.h b/drivers/net/dsa/hirsc= hmann/hellcreek.h index 9c2ed2ba79da..bebf0d3ff330 100644 --- a/drivers/net/dsa/hirschmann/hellcreek.h +++ b/drivers/net/dsa/hirschmann/hellcreek.h @@ -244,7 +244,7 @@ struct hellcreek_port_hwtstamp { struct sk_buff *tx_skb; =20 /* Current timestamp configuration */ - struct hwtstamp_config tstamp_config; + struct kernel_hwtstamp_config tstamp_config; }; =20 struct hellcreek_port { diff --git a/drivers/net/dsa/hirschmann/hellcreek_hwtstamp.c b/drivers/net/= dsa/hirschmann/hellcreek_hwtstamp.c index ca2500aba96f..99941ff1ebf9 100644 --- a/drivers/net/dsa/hirschmann/hellcreek_hwtstamp.c +++ b/drivers/net/dsa/hirschmann/hellcreek_hwtstamp.c @@ -40,7 +40,7 @@ int hellcreek_get_ts_info(struct dsa_switch *ds, int port, * the user requested what is actually available or not */ static int hellcreek_set_hwtstamp_config(struct hellcreek *hellcreek, int = port, - struct hwtstamp_config *config) + struct kernel_hwtstamp_config *config) { struct hellcreek_port_hwtstamp *ps =3D &hellcreek->ports[port].port_hwtstamp; @@ -110,41 +110,35 @@ static int hellcreek_set_hwtstamp_config(struct hellc= reek *hellcreek, int port, } =20 int hellcreek_port_hwtstamp_set(struct dsa_switch *ds, int port, - struct ifreq *ifr) + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack) { struct hellcreek *hellcreek =3D ds->priv; struct hellcreek_port_hwtstamp *ps; - struct hwtstamp_config config; int err; =20 ps =3D &hellcreek->ports[port].port_hwtstamp; =20 - if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) - return -EFAULT; - - err =3D hellcreek_set_hwtstamp_config(hellcreek, port, &config); + err =3D hellcreek_set_hwtstamp_config(hellcreek, port, config); if (err) return err; =20 /* Save the chosen configuration to be returned later */ - memcpy(&ps->tstamp_config, &config, sizeof(config)); + ps->tstamp_config =3D *config; =20 - return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? - -EFAULT : 0; + return 0; } =20 int hellcreek_port_hwtstamp_get(struct dsa_switch *ds, int port, - struct ifreq *ifr) + struct kernel_hwtstamp_config *config) { struct hellcreek *hellcreek =3D ds->priv; struct hellcreek_port_hwtstamp *ps; - struct hwtstamp_config *config; =20 ps =3D &hellcreek->ports[port].port_hwtstamp; - config =3D &ps->tstamp_config; + *config =3D ps->tstamp_config; =20 - return copy_to_user(ifr->ifr_data, config, sizeof(*config)) ? - -EFAULT : 0; + return 0; } =20 /* Returns a pointer to the PTP header if the caller should time stamp, or= NULL diff --git a/drivers/net/dsa/hirschmann/hellcreek_hwtstamp.h b/drivers/net/= dsa/hirschmann/hellcreek_hwtstamp.h index 7d88da2134f2..388821c4aa10 100644 --- a/drivers/net/dsa/hirschmann/hellcreek_hwtstamp.h +++ b/drivers/net/dsa/hirschmann/hellcreek_hwtstamp.h @@ -38,9 +38,10 @@ #define TX_TSTAMP_TIMEOUT msecs_to_jiffies(40) =20 int hellcreek_port_hwtstamp_set(struct dsa_switch *ds, int port, - struct ifreq *ifr); + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack); int hellcreek_port_hwtstamp_get(struct dsa_switch *ds, int port, - struct ifreq *ifr); + struct kernel_hwtstamp_config *config); =20 bool hellcreek_port_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *clone, unsigned int type); diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index dd5429ff16ee..a034017568cd 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -142,7 +142,7 @@ struct ksz_port { struct ksz_irq pirq; u8 num; #if IS_ENABLED(CONFIG_NET_DSA_MICROCHIP_KSZ_PTP) - struct hwtstamp_config tstamp_config; + struct kernel_hwtstamp_config tstamp_config; bool hwts_tx_en; bool hwts_rx_en; struct ksz_irq ptpirq; diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index 22fb9ef4645c..bc54a96ba646 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -319,22 +319,21 @@ int ksz_get_ts_info(struct dsa_switch *ds, int port, = struct kernel_ethtool_ts_in return 0; } =20 -int ksz_hwtstamp_get(struct dsa_switch *ds, int port, struct ifreq *ifr) +int ksz_hwtstamp_get(struct dsa_switch *ds, int port, + struct kernel_hwtstamp_config *config) { struct ksz_device *dev =3D ds->priv; - struct hwtstamp_config *config; struct ksz_port *prt; =20 prt =3D &dev->ports[port]; - config =3D &prt->tstamp_config; + *config =3D prt->tstamp_config; =20 - return copy_to_user(ifr->ifr_data, config, sizeof(*config)) ? - -EFAULT : 0; + return 0; } =20 static int ksz_set_hwtstamp_config(struct ksz_device *dev, struct ksz_port *prt, - struct hwtstamp_config *config) + struct kernel_hwtstamp_config *config) { int ret; =20 @@ -404,26 +403,21 @@ static int ksz_set_hwtstamp_config(struct ksz_device = *dev, return ksz_ptp_enable_mode(dev); } =20 -int ksz_hwtstamp_set(struct dsa_switch *ds, int port, struct ifreq *ifr) +int ksz_hwtstamp_set(struct dsa_switch *ds, int port, + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack) { struct ksz_device *dev =3D ds->priv; - struct hwtstamp_config config; struct ksz_port *prt; int ret; =20 prt =3D &dev->ports[port]; =20 - if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) - return -EFAULT; - - ret =3D ksz_set_hwtstamp_config(dev, prt, &config); + ret =3D ksz_set_hwtstamp_config(dev, prt, config); if (ret) return ret; =20 - memcpy(&prt->tstamp_config, &config, sizeof(config)); - - if (copy_to_user(ifr->ifr_data, &config, sizeof(config))) - return -EFAULT; + prt->tstamp_config =3D *config; =20 return 0; } diff --git a/drivers/net/dsa/microchip/ksz_ptp.h b/drivers/net/dsa/microchi= p/ksz_ptp.h index 2f1783c0d723..3086e519b1b6 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.h +++ b/drivers/net/dsa/microchip/ksz_ptp.h @@ -39,8 +39,11 @@ void ksz_ptp_clock_unregister(struct dsa_switch *ds); =20 int ksz_get_ts_info(struct dsa_switch *ds, int port, struct kernel_ethtool_ts_info *ts); -int ksz_hwtstamp_get(struct dsa_switch *ds, int port, struct ifreq *ifr); -int ksz_hwtstamp_set(struct dsa_switch *ds, int port, struct ifreq *ifr); +int ksz_hwtstamp_get(struct dsa_switch *ds, int port, + struct kernel_hwtstamp_config *config); +int ksz_hwtstamp_set(struct dsa_switch *ds, int port, + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack); void ksz_port_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *sk= b); void ksz_port_deferred_xmit(struct kthread_work *work); bool ksz_port_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *sk= b, diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/c= hip.h index 86bf113c9bfa..7d00482f53a3 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.h +++ b/drivers/net/dsa/mv88e6xxx/chip.h @@ -241,7 +241,7 @@ struct mv88e6xxx_port_hwtstamp { u16 tx_seq_id; =20 /* Current timestamp configuration */ - struct hwtstamp_config tstamp_config; + struct kernel_hwtstamp_config tstamp_config; }; =20 enum mv88e6xxx_policy_mapping { diff --git a/drivers/net/dsa/mv88e6xxx/hwtstamp.c b/drivers/net/dsa/mv88e6x= xx/hwtstamp.c index 49e6e1355142..f663799b0b3b 100644 --- a/drivers/net/dsa/mv88e6xxx/hwtstamp.c +++ b/drivers/net/dsa/mv88e6xxx/hwtstamp.c @@ -89,7 +89,7 @@ int mv88e6xxx_get_ts_info(struct dsa_switch *ds, int port, } =20 static int mv88e6xxx_set_hwtstamp_config(struct mv88e6xxx_chip *chip, int = port, - struct hwtstamp_config *config) + struct kernel_hwtstamp_config *config) { const struct mv88e6xxx_ptp_ops *ptp_ops =3D chip->info->ops->ptp_ops; struct mv88e6xxx_port_hwtstamp *ps =3D &chip->port_hwtstamp[port]; @@ -169,42 +169,38 @@ static int mv88e6xxx_set_hwtstamp_config(struct mv88e= 6xxx_chip *chip, int port, } =20 int mv88e6xxx_port_hwtstamp_set(struct dsa_switch *ds, int port, - struct ifreq *ifr) + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack) { struct mv88e6xxx_chip *chip =3D ds->priv; struct mv88e6xxx_port_hwtstamp *ps =3D &chip->port_hwtstamp[port]; - struct hwtstamp_config config; int err; =20 if (!chip->info->ptp_support) return -EOPNOTSUPP; =20 - if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) - return -EFAULT; - - err =3D mv88e6xxx_set_hwtstamp_config(chip, port, &config); + err =3D mv88e6xxx_set_hwtstamp_config(chip, port, config); if (err) return err; =20 /* Save the chosen configuration to be returned later. */ - memcpy(&ps->tstamp_config, &config, sizeof(config)); + ps->tstamp_config =3D *config; =20 - return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? - -EFAULT : 0; + return 0; } =20 int mv88e6xxx_port_hwtstamp_get(struct dsa_switch *ds, int port, - struct ifreq *ifr) + struct kernel_hwtstamp_config *config) { struct mv88e6xxx_chip *chip =3D ds->priv; struct mv88e6xxx_port_hwtstamp *ps =3D &chip->port_hwtstamp[port]; - struct hwtstamp_config *config =3D &ps->tstamp_config; =20 if (!chip->info->ptp_support) return -EOPNOTSUPP; =20 - return copy_to_user(ifr->ifr_data, config, sizeof(*config)) ? - -EFAULT : 0; + *config =3D ps->tstamp_config; + + return 0; } =20 /* Returns a pointer to the PTP header if the caller should time stamp, diff --git a/drivers/net/dsa/mv88e6xxx/hwtstamp.h b/drivers/net/dsa/mv88e6x= xx/hwtstamp.h index 85acc758e3eb..22e4acc957f0 100644 --- a/drivers/net/dsa/mv88e6xxx/hwtstamp.h +++ b/drivers/net/dsa/mv88e6xxx/hwtstamp.h @@ -111,9 +111,10 @@ #ifdef CONFIG_NET_DSA_MV88E6XXX_PTP =20 int mv88e6xxx_port_hwtstamp_set(struct dsa_switch *ds, int port, - struct ifreq *ifr); + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack); int mv88e6xxx_port_hwtstamp_get(struct dsa_switch *ds, int port, - struct ifreq *ifr); + struct kernel_hwtstamp_config *cfg); =20 bool mv88e6xxx_port_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *clone, unsigned int type); @@ -132,14 +133,17 @@ int mv88e6165_global_disable(struct mv88e6xxx_chip *c= hip); =20 #else /* !CONFIG_NET_DSA_MV88E6XXX_PTP */ =20 -static inline int mv88e6xxx_port_hwtstamp_set(struct dsa_switch *ds, - int port, struct ifreq *ifr) +static inline int +mv88e6xxx_port_hwtstamp_set(struct dsa_switch *ds, int port, + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack) { return -EOPNOTSUPP; } =20 -static inline int mv88e6xxx_port_hwtstamp_get(struct dsa_switch *ds, - int port, struct ifreq *ifr) +static inline int +mv88e6xxx_port_hwtstamp_get(struct dsa_switch *ds, int port, + struct kernel_hwtstamp_config *config) { return -EOPNOTSUPP; } diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 0a4e682a55ef..2dd4e56e1cf1 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -1774,22 +1774,25 @@ static void felix_teardown(struct dsa_switch *ds) } =20 static int felix_hwtstamp_get(struct dsa_switch *ds, int port, - struct ifreq *ifr) + struct kernel_hwtstamp_config *config) { struct ocelot *ocelot =3D ds->priv; =20 - return ocelot_hwstamp_get(ocelot, port, ifr); + ocelot_hwstamp_get(ocelot, port, config); + + return 0; } =20 static int felix_hwtstamp_set(struct dsa_switch *ds, int port, - struct ifreq *ifr) + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack) { struct ocelot *ocelot =3D ds->priv; struct felix *felix =3D ocelot_to_felix(ocelot); bool using_tag_8021q; int err; =20 - err =3D ocelot_hwstamp_set(ocelot, port, ifr); + err =3D ocelot_hwstamp_set(ocelot, port, config, extack); if (err) return err; =20 diff --git a/drivers/net/dsa/sja1105/sja1105_ptp.c b/drivers/net/dsa/sja110= 5/sja1105_ptp.c index 3abc64aec411..fefe46e2a5e6 100644 --- a/drivers/net/dsa/sja1105/sja1105_ptp.c +++ b/drivers/net/dsa/sja1105/sja1105_ptp.c @@ -58,19 +58,17 @@ enum sja1105_ptp_clk_mode { #define ptp_data_to_sja1105(d) \ container_of((d), struct sja1105_private, ptp_data) =20 -int sja1105_hwtstamp_set(struct dsa_switch *ds, int port, struct ifreq *if= r) +int sja1105_hwtstamp_set(struct dsa_switch *ds, int port, + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack) { struct sja1105_private *priv =3D ds->priv; unsigned long hwts_tx_en, hwts_rx_en; - struct hwtstamp_config config; - - if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) - return -EFAULT; =20 hwts_tx_en =3D priv->hwts_tx_en; hwts_rx_en =3D priv->hwts_rx_en; =20 - switch (config.tx_type) { + switch (config->tx_type) { case HWTSTAMP_TX_OFF: hwts_tx_en &=3D ~BIT(port); break; @@ -81,7 +79,7 @@ int sja1105_hwtstamp_set(struct dsa_switch *ds, int port,= struct ifreq *ifr) return -ERANGE; } =20 - switch (config.rx_filter) { + switch (config->rx_filter) { case HWTSTAMP_FILTER_NONE: hwts_rx_en &=3D ~BIT(port); break; @@ -92,32 +90,28 @@ int sja1105_hwtstamp_set(struct dsa_switch *ds, int por= t, struct ifreq *ifr) return -ERANGE; } =20 - if (copy_to_user(ifr->ifr_data, &config, sizeof(config))) - return -EFAULT; - priv->hwts_tx_en =3D hwts_tx_en; priv->hwts_rx_en =3D hwts_rx_en; =20 return 0; } =20 -int sja1105_hwtstamp_get(struct dsa_switch *ds, int port, struct ifreq *if= r) +int sja1105_hwtstamp_get(struct dsa_switch *ds, int port, + struct kernel_hwtstamp_config *config) { struct sja1105_private *priv =3D ds->priv; - struct hwtstamp_config config; =20 - config.flags =3D 0; + config->flags =3D 0; if (priv->hwts_tx_en & BIT(port)) - config.tx_type =3D HWTSTAMP_TX_ON; + config->tx_type =3D HWTSTAMP_TX_ON; else - config.tx_type =3D HWTSTAMP_TX_OFF; + config->tx_type =3D HWTSTAMP_TX_OFF; if (priv->hwts_rx_en & BIT(port)) - config.rx_filter =3D HWTSTAMP_FILTER_PTP_V2_L2_EVENT; + config->rx_filter =3D HWTSTAMP_FILTER_PTP_V2_L2_EVENT; else - config.rx_filter =3D HWTSTAMP_FILTER_NONE; + config->rx_filter =3D HWTSTAMP_FILTER_NONE; =20 - return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? - -EFAULT : 0; + return 0; } =20 int sja1105_get_ts_info(struct dsa_switch *ds, int port, diff --git a/drivers/net/dsa/sja1105/sja1105_ptp.h b/drivers/net/dsa/sja110= 5/sja1105_ptp.h index 8add2bd5f728..325e3777ea07 100644 --- a/drivers/net/dsa/sja1105/sja1105_ptp.h +++ b/drivers/net/dsa/sja1105/sja1105_ptp.h @@ -112,9 +112,12 @@ bool sja1105_port_rxtstamp(struct dsa_switch *ds, int = port, void sja1105_port_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb); =20 -int sja1105_hwtstamp_get(struct dsa_switch *ds, int port, struct ifreq *if= r); +int sja1105_hwtstamp_get(struct dsa_switch *ds, int port, + struct kernel_hwtstamp_config *config); =20 -int sja1105_hwtstamp_set(struct dsa_switch *ds, int port, struct ifreq *if= r); +int sja1105_hwtstamp_set(struct dsa_switch *ds, int port, + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack); =20 int __sja1105_ptp_gettimex(struct dsa_switch *ds, u64 *ns, struct ptp_system_timestamp *sts); diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/= mscc/ocelot_net.c index 7663d196eaf8..469784d3a1a6 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -869,24 +869,31 @@ static int ocelot_set_features(struct net_device *dev, } =20 static int ocelot_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) +{ + return phy_mii_ioctl(dev->phydev, ifr, cmd); +} + +static int ocelot_port_hwtstamp_get(struct net_device *dev, + struct kernel_hwtstamp_config *cfg) { struct ocelot_port_private *priv =3D netdev_priv(dev); struct ocelot *ocelot =3D priv->port.ocelot; int port =3D priv->port.index; =20 - /* If the attached PHY device isn't capable of timestamping operations, - * use our own (when possible). - */ - if (!phy_has_hwtstamp(dev->phydev) && ocelot->ptp) { - switch (cmd) { - case SIOCSHWTSTAMP: - return ocelot_hwstamp_set(ocelot, port, ifr); - case SIOCGHWTSTAMP: - return ocelot_hwstamp_get(ocelot, port, ifr); - } - } + ocelot_hwstamp_get(ocelot, port, cfg); =20 - return phy_mii_ioctl(dev->phydev, ifr, cmd); + return 0; +} + +static int ocelot_port_hwtstamp_set(struct net_device *dev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) +{ + struct ocelot_port_private *priv =3D netdev_priv(dev); + struct ocelot *ocelot =3D priv->port.ocelot; + int port =3D priv->port.index; + + return ocelot_hwstamp_set(ocelot, port, cfg, extack); } =20 static int ocelot_change_mtu(struct net_device *dev, int new_mtu) @@ -917,6 +924,8 @@ static const struct net_device_ops ocelot_port_netdev_o= ps =3D { .ndo_set_features =3D ocelot_set_features, .ndo_setup_tc =3D ocelot_setup_tc, .ndo_eth_ioctl =3D ocelot_ioctl, + .ndo_hwtstamp_get =3D ocelot_port_hwtstamp_get, + .ndo_hwtstamp_set =3D ocelot_port_hwtstamp_set, }; =20 struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port) diff --git a/drivers/net/ethernet/mscc/ocelot_ptp.c b/drivers/net/ethernet/= mscc/ocelot_ptp.c index d2a0a32f75ea..88b5422cc2a0 100644 --- a/drivers/net/ethernet/mscc/ocelot_ptp.c +++ b/drivers/net/ethernet/mscc/ocelot_ptp.c @@ -514,47 +514,42 @@ static int ocelot_ptp_tx_type_to_cmd(int tx_type, int= *ptp_cmd) return 0; } =20 -int ocelot_hwstamp_get(struct ocelot *ocelot, int port, struct ifreq *ifr) +void ocelot_hwstamp_get(struct ocelot *ocelot, int port, + struct kernel_hwtstamp_config *cfg) { struct ocelot_port *ocelot_port =3D ocelot->ports[port]; - struct hwtstamp_config cfg =3D {}; =20 switch (ocelot_port->ptp_cmd) { case IFH_REW_OP_TWO_STEP_PTP: - cfg.tx_type =3D HWTSTAMP_TX_ON; + cfg->tx_type =3D HWTSTAMP_TX_ON; break; case IFH_REW_OP_ORIGIN_PTP: - cfg.tx_type =3D HWTSTAMP_TX_ONESTEP_SYNC; + cfg->tx_type =3D HWTSTAMP_TX_ONESTEP_SYNC; break; default: - cfg.tx_type =3D HWTSTAMP_TX_OFF; + cfg->tx_type =3D HWTSTAMP_TX_OFF; break; } =20 - cfg.rx_filter =3D ocelot_traps_to_ptp_rx_filter(ocelot_port->trap_proto); - - return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; + cfg->rx_filter =3D ocelot_traps_to_ptp_rx_filter(ocelot_port->trap_proto); } EXPORT_SYMBOL(ocelot_hwstamp_get); =20 -int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr) +int ocelot_hwstamp_set(struct ocelot *ocelot, int port, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) { struct ocelot_port *ocelot_port =3D ocelot->ports[port]; - int ptp_cmd, old_ptp_cmd =3D ocelot_port->ptp_cmd; bool l2 =3D false, l4 =3D false; - struct hwtstamp_config cfg; - bool old_l2, old_l4; + int ptp_cmd; int err; =20 - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) - return -EFAULT; - /* Tx type sanity check */ - err =3D ocelot_ptp_tx_type_to_cmd(cfg.tx_type, &ptp_cmd); + err =3D ocelot_ptp_tx_type_to_cmd(cfg->tx_type, &ptp_cmd); if (err) return err; =20 - switch (cfg.rx_filter) { + switch (cfg->rx_filter) { case HWTSTAMP_FILTER_NONE: break; case HWTSTAMP_FILTER_PTP_V2_L4_EVENT: @@ -577,27 +572,15 @@ int ocelot_hwstamp_set(struct ocelot *ocelot, int por= t, struct ifreq *ifr) return -ERANGE; } =20 - old_l2 =3D ocelot_port->trap_proto & OCELOT_PROTO_PTP_L2; - old_l4 =3D ocelot_port->trap_proto & OCELOT_PROTO_PTP_L4; - err =3D ocelot_setup_ptp_traps(ocelot, port, l2, l4); if (err) return err; =20 ocelot_port->ptp_cmd =3D ptp_cmd; =20 - cfg.rx_filter =3D ocelot_traps_to_ptp_rx_filter(ocelot_port->trap_proto); - - if (copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg))) { - err =3D -EFAULT; - goto out_restore_ptp_traps; - } + cfg->rx_filter =3D ocelot_traps_to_ptp_rx_filter(ocelot_port->trap_proto); =20 return 0; -out_restore_ptp_traps: - ocelot_setup_ptp_traps(ocelot, port, old_l2, old_l4); - ocelot_port->ptp_cmd =3D old_ptp_cmd; - return err; } EXPORT_SYMBOL(ocelot_hwstamp_set); =20 diff --git a/include/net/dsa.h b/include/net/dsa.h index a0a9481c52c2..55e2d97f247e 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -1131,9 +1131,10 @@ struct dsa_switch_ops { * PTP functionality */ int (*port_hwtstamp_get)(struct dsa_switch *ds, int port, - struct ifreq *ifr); + struct kernel_hwtstamp_config *config); int (*port_hwtstamp_set)(struct dsa_switch *ds, int port, - struct ifreq *ifr); + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack); void (*port_txtstamp)(struct dsa_switch *ds, int port, struct sk_buff *skb); bool (*port_rxtstamp)(struct dsa_switch *ds, int port, diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 6db7fc9dbaa4..48d6deb3efd7 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -1073,8 +1073,11 @@ int ocelot_vlan_prepare(struct ocelot *ocelot, int p= ort, u16 vid, bool pvid, int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, bool untagged); int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid); -int ocelot_hwstamp_get(struct ocelot *ocelot, int port, struct ifreq *ifr); -int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr); +void ocelot_hwstamp_get(struct ocelot *ocelot, int port, + struct kernel_hwtstamp_config *cfg); +int ocelot_hwstamp_set(struct ocelot *ocelot, int port, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack); int ocelot_port_txtstamp_request(struct ocelot *ocelot, int port, struct sk_buff *skb, struct sk_buff **clone); diff --git a/net/dsa/port.c b/net/dsa/port.c index 5c9d1798e830..082573ae6864 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -116,19 +116,15 @@ static bool dsa_port_can_configure_learning(struct ds= a_port *dp) =20 bool dsa_port_supports_hwtstamp(struct dsa_port *dp) { + struct kernel_hwtstamp_config config =3D {}; struct dsa_switch *ds =3D dp->ds; - struct ifreq ifr =3D {}; int err; =20 if (!ds->ops->port_hwtstamp_get || !ds->ops->port_hwtstamp_set) return false; =20 - /* "See through" shim implementations of the "get" method. - * Since we can't cook up a complete ioctl request structure, this will - * fail in copy_to_user() with -EFAULT, which hopefully is enough to - * detect a valid implementation. - */ - err =3D ds->ops->port_hwtstamp_get(ds, dp->index, &ifr); + /* "See through" shim implementations of the "get" method. */ + err =3D ds->ops->port_hwtstamp_get(ds, dp->index, &config); return err !=3D -EOPNOTSUPP; } =20 diff --git a/net/dsa/user.c b/net/dsa/user.c index 804dc7dac4f2..e9334520c54a 100644 --- a/net/dsa/user.c +++ b/net/dsa/user.c @@ -578,20 +578,6 @@ dsa_user_fdb_dump(struct sk_buff *skb, struct netlink_= callback *cb, static int dsa_user_ioctl(struct net_device *dev, struct ifreq *ifr, int c= md) { struct dsa_user_priv *p =3D netdev_priv(dev); - struct dsa_switch *ds =3D p->dp->ds; - int port =3D p->dp->index; - - /* Pass through to switch driver if it supports timestamping */ - switch (cmd) { - case SIOCGHWTSTAMP: - if (ds->ops->port_hwtstamp_get) - return ds->ops->port_hwtstamp_get(ds, port, ifr); - break; - case SIOCSHWTSTAMP: - if (ds->ops->port_hwtstamp_set) - return ds->ops->port_hwtstamp_set(ds, port, ifr); - break; - } =20 return phylink_mii_ioctl(p->dp->pl, ifr, cmd); } @@ -2574,6 +2560,31 @@ static int dsa_user_fill_forward_path(struct net_dev= ice_path_ctx *ctx, return 0; } =20 +static int dsa_user_hwtstamp_get(struct net_device *dev, + struct kernel_hwtstamp_config *cfg) +{ + struct dsa_port *dp =3D dsa_user_to_port(dev); + struct dsa_switch *ds =3D dp->ds; + + if (!ds->ops->port_hwtstamp_get) + return -EOPNOTSUPP; + + return ds->ops->port_hwtstamp_get(ds, dp->index, cfg); +} + +static int dsa_user_hwtstamp_set(struct net_device *dev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) +{ + struct dsa_port *dp =3D dsa_user_to_port(dev); + struct dsa_switch *ds =3D dp->ds; + + if (!ds->ops->port_hwtstamp_set) + return -EOPNOTSUPP; + + return ds->ops->port_hwtstamp_set(ds, dp->index, cfg, extack); +} + static const struct net_device_ops dsa_user_netdev_ops =3D { .ndo_open =3D dsa_user_open, .ndo_stop =3D dsa_user_close, @@ -2595,6 +2606,8 @@ static const struct net_device_ops dsa_user_netdev_op= s =3D { .ndo_vlan_rx_kill_vid =3D dsa_user_vlan_rx_kill_vid, .ndo_change_mtu =3D dsa_user_change_mtu, .ndo_fill_forward_path =3D dsa_user_fill_forward_path, + .ndo_hwtstamp_get =3D dsa_user_hwtstamp_get, + .ndo_hwtstamp_set =3D dsa_user_hwtstamp_set, }; =20 static const struct device_type dsa_type =3D { --=20 2.43.0