From patchwork Thu May 8 19:48:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 889308 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) (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 7CDD4288529; Thu, 8 May 2025 19:48:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746733731; cv=fail; b=bT+/5LNR+qO7HcX1pdcYJshu1p4DoKykp2UIV+6JDt6NcyuWhUkgCdHre37gkEm4KfodgUiFZocymYadB82brlaefZuf+ZY5epmrysW1UgFl5RsaQP+locaWaUdJS+mZg2Nvyeo0ZbsxTX/Tuz+Sm3jrIwKhBEyMY4eZk7Rlbdk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746733731; c=relaxed/simple; bh=GvatIawSNaoBqIRaBoR9Gs0YfZ7/qk9ViBwiPcfoYpI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=pj+INZqjTNTkcXVDB4COTKetD9OKEX0ZlGFt7344YTwY+r/XLxgRBHSxykw+xOZwBrGcf8Sb64NQ+eqvGuS84uJOX7zVHY/eD5Tgr5R4BIz3Ztn+p6T4m9JMs73+U+9OP0VGvsNgc8LDROS9sFMifBhIEP0B7BqdFX6hztiCV5c= 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=RaGVySoL; arc=fail smtp.client-ip=40.107.22.71 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="RaGVySoL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qGDzoWu6mhXbWrKzmomP76MlQHMucQOtqrxCZNn4nJCZaAfT2KLTRDf3KV3IrlcMANsfiH2s4Op4OiH0smiuh7J5/E3GZTEjN9WYrHlDmotrdVpUafYuvI1oEp0UH+BMAptf+K3qqaSF1CDVdd6CNS/XtGQ13Pbh46FN9yE4AVkiWc2Ql0zsV7iE/xnCCdM3AqDxCV5NNlNzHPA3Cx7tRyyA9YRQe6LBD8wqaLJIOcHbaqkNhkjnebzneOj3qfNrIac4lxj8R1+rC6dNYGpT5ZX6Pm0Ehm4JINp9PxkDrbxhqxmJSTC66qiDEDfQttscgfA2JazFzF2/BqJa33Hh/g== 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=yA7BiMV7QooS03S6VFFxjzCmgwSJJvvJhpQAwmIQKkU=; b=ToievGF4TOszIOjSKEYSrisjf/vuZ2WfIBJj6E9sWKNomRlHs9B6YN0oag3F4dXonfLtWvxpX5f0bCXjaYy4JjSI7P8gASv5wWYg1noAWLNET0B/nlzbEHvcEmjnVYMEMCj+hyL7VbBE24gQa6SsT1G1OTORjRqRJDgN8SV6JAGbfh27tc3Q9iZrbDB/BMrv1RhpnAt/gOS0IlcrUcFlAb9lLPh1VLGS6wggDIIh7NPwXmQ1kcytw13fw85mdqW0LMg6dp8IkQd0EAwT6cUVOWqROwkEhhn3NDn2muqj9wiEqmAKss/fabEijl+Hq0MfUdgfaMfOGtvrpzJKP/YgbA== 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=yA7BiMV7QooS03S6VFFxjzCmgwSJJvvJhpQAwmIQKkU=; b=RaGVySoLr3ohQ/HFq/jRnUFaBPTvhJ+4A770SmlZQBxyshb6Gq75+qAPC+PGAaAJohujpuTcbgeTmGH2v4/I+/+TUdRcSsnGcA77GkpQ2GJP3RYK+FRkUMczGKTgjACGDpXP8hSPyDfhNFO1IQr2IRwifISvVU0dSvzpsEJQN7d4xeCW4NaH8f4pnHNxwUJe9jlyOtFi9vzkAtASN5CKD6LyzJiU2tTnv7DlH2IEmss15Juf80IXzZ/JkJTK3X6Tj2SbZdhU5jst7cJwrr2qJYvLy5LKNT02Ys+fZBfQ3Vn9NTjJ2M3Cy2oXS4PFWFCLd4mkC5cDO4NrQhECpGIckA== 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 DB9PR04MB8395.eurprd04.prod.outlook.com (2603:10a6:10:247::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.33; Thu, 8 May 2025 19:48:42 +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 19:48:42 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: =?utf-8?q?K=C3=B6ry_Maincent?= , Andrew Lunn , Siddharth Vadapalli , Roger Quadros , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Richard Cochran , Russell King , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH net-next 1/3] net: cpsw: return proper RX timestamping filter in cpsw_hwtstamp_get() Date: Thu, 8 May 2025 22:48:23 +0300 Message-ID: <20250508194825.3058929-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250508194825.3058929-1-vladimir.oltean@nxp.com> References: <20250508194825.3058929-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0471.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7f::10) To AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) Precedence: bulk X-Mailing-List: linux-omap@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM8PR04MB7779:EE_|DB9PR04MB8395:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d7e3a57-442d-4859-2d1b-08dd8e6955cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: wE97FfXH/UZE0B8VIoM3H9Q5s7LXkBkIjRszFgcD+ivnD0r4euK2aWgZbGJ0qMmaQdhNu99+n2fj2CNkBwgU9z4ZfsYldYyrHa5qw0pWoUEYNetriZEQCt7jImZCYlszHBzfgxXuM1kf3R7YE222ElM0PcRCqdA2FDe1g95sW+85hPs4zZJPKNKUIHjlAxDwls9msNR2TjC498JnNvkQ3zRpC0Gt6Xmb+RMTec+QBDtKN9Ft2MvLLNuhXv7fbC9SaAsLjUZqoPy33/1LZUxgBkt8UiCw75FEO3jfa4hA3chwdTMmx9TATTVdh5Qv96iTNK3mhBLYFl4j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ljh+roly1Dj/Nw7YUdKPTrR8GeM9zmzGpbuBe3iVaBGzKtR8/lBAeEto2SK1oPJtFoQor2UCiv4TD4mVt5RyIUThmKeCjwM8HL286NtHw== 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)(7416014)(52116014)(376014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kMk/+V/k/25TUT0tMv1qbZ64meS8JjWqsM24x/jglzpGkjNQxZbRKJZMvHiWEOLeELnv9kTWo5YfqkzhG0/A/FV+l2cDo2aNf1X3nA/p9VM+cn6hvMfTN1isyTdms/f8XaPBCenMwg2ISNU7/ABBT5j1GtIjdENUsotz3VeJ7kfPDc4zTe7blcTs8AVfkTiW0CiD7H9dyBe4kEY91vUktawdDRcEG+OFT3My1J6lrkokzWj0MeNC3VKlt3KBKDYLcVDxvhEjGtCtkYYv+aN4FQKemJTsri4QUBCRrbpgrOEit5zEGhOaycRXzv60s0F5KujeL+dnS0b6OlZgZy9Vqk93QG+3xSI6k7MOUDSBI6v4dkdG6AX7Qv4yWY8tNHwk92dDvT2vYgQ0QghG1O5dZ27LigrxAxVLIcvTqRJVbyRsnJRxf9gx9kZ6eOchVkoA0wjP3PM7GwXDMxNKnapo21vKegGeWGNxOPgsC1maMFwRg47yy5XY353IdNSz2t17i8W3n+zxHV3oRGm6c/fk8rX8FeSQbbJKiFEi4hoRvfcFw8sPyLxGDfHKot9T6fg2zsCiA12KS692jH5n3pHWmkVFbkXg8EGKPy+vfzFrLERK7Wwn3Y7/eitDmsg95Nvc1arKVsUQRF4uS9LncoIR9j1lGYMcVSmUOyVITJmldGvQlSwdSePpGiyVBK1QpfMLqXgJAGYbNs+85JoMy0RqHBib5EHeynAyk5MyO0dMGM7jvyx7zmJSfn3DpW2KElnOmffiox6V71ADuOZpvequmU0VCu5qttur+sV6WaKLUURLe7PLVI2WWSTJ9axlvCbq3ooOBMOwePv1cgH89aiNZV87ku3wN8c4YOtqUPzJif+r0E15mMZqUx/pnPd5EPMgFC5L/afw2howQBtnUmvBJY3cjQBti+Tq8GixBuu1YXjtnn7papuEaWhX3LRFMHIFAtxsJwwzIpkcY8IML9he9WB1Jus9tSuh5hKqXodrBi8WI3zxsJQPMZeM1bp1b2ydiUXzkxTd1YUNEhAncKjih1B+az6HgmzcFp1HNYKD1+bMC5AUdTw3ErkOQoFQsSnNeWKjDIHxgYBMo9nOpLOiUmv0D42GuXLyYPUR51Nb+5ndVKMjG+NZJvMHlH7pm/QpVbmr9tgJ+OHTeF7fejJXHCp5hpB81n0iHrBbWY9q4FBTUDwkEoogh0qQ2WMAedv9F1VVaH9kkkbGn4R++3UPBWRcNNrMPVA/d+0xAa1ljoWXnj6U1aQwNOh0YBT/jKmp0YRjGDTLO7hTaHJtmdO1LZpVaf28QC33bsVyYUauHSRBXtU9ZEXQFtkR8rgK3iEdX6fCYIxFh8CZnDY9+VFY3u0yhDBjIAwKjpaDwLU46kXS48Pi0ojJ6S6yhTQodnxJ6QNX/lEeWosdQ9H6R1mEnaKHuD5DldcGXdMUDmlfBNlr2srxYcNNEgE1Rp4qVLHTfqShDf+ohbTwjaOzEVf0P91eaafLYdwcgKeQ7USGLsKv+y4hEM9pcE2jsquBd9qayos1fmWDeOG7QZqVUqrrosT054pH5zs0K24gIm9Kof8XBoS23EanlE3HKl7NCMQIfUVSrczOaNWz/I8QJN705A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d7e3a57-442d-4859-2d1b-08dd8e6955cd X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2025 19:48:42.0706 (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: 8ddZPp8jTsKQudFP91uSEx6jXqPbmmuUc46jIotbiTqObOhdUync6cW2f9U8bq5+WPKlNVsH5EuvXm+alBdWmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8395 priv->rx_ts_enabled is a boolean variable (0 or 1). Overlapped over enum hwtstamp_rx_filters, it makes cfg.rx_filter take the value of either HWTSTAMP_FILTER_NONE (when 0) or HWTSTAMP_FILTER_ALL (when 1). But this is inconsistent with what is returned in cpsw_hwtstamp_set(). There, HWTSTAMP_FILTER_ALL is refused (-ERANGE), and a subset of the RX filters requestable by user space are all replaced with HWTSTAMP_FILTER_PTP_V2_EVENT. So the driver should be reporting this value during SIOCGHWTSTAMP as well. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/ti/cpsw_priv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c index 6fe4edabba44..68d8f7ea0e44 100644 --- a/drivers/net/ethernet/ti/cpsw_priv.c +++ b/drivers/net/ethernet/ti/cpsw_priv.c @@ -687,7 +687,8 @@ static int cpsw_hwtstamp_get(struct net_device *dev, struct ifreq *ifr) cfg.flags = 0; cfg.tx_type = priv->tx_ts_enabled ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; - cfg.rx_filter = priv->rx_ts_enabled; + cfg.rx_filter = priv->rx_ts_enabled ? HWTSTAMP_FILTER_PTP_V2_EVENT : + HWTSTAMP_FILTER_NONE; return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; } From patchwork Thu May 8 19:48:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 888748 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) (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 BA54F28B51F; Thu, 8 May 2025 19:48:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746733734; cv=fail; b=huPvdK4boQ/Hb+9557fH5xoyFtGkVp0ez4ZdSRqFCvS5hG/I/VA2kHr5DMAiZTE72CbB1+1ziIi839tVF17DZWpEJOEOEJ6D9zm/nyCAo/rwxb4dB+Bd1LrYhacf5h/YauyAytjiQnEH/Qimfny14VD34EVopgDh5qrMMIF2B1Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746733734; c=relaxed/simple; bh=4HiwZn8PczWXqYyciVT4KsmbWJlv0iWB+yOzTsVdl6c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=C9g44FuBsusGaaOb8rRTnyw6ywFieuAAsH1XxsWeUa+cHw5u2i5WWGMtishlv4gXA1IRa061IzhAmERkw/zAPG74t1EZmcbfxJztsoxUUpLiKJmLmc+VKTYyVmO4SEqcjo3WD0Kq0DbdhnEsgKcpQICa9M4YPcy+/cSNQ5CMdHs= 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=QWpMXuUK; arc=fail smtp.client-ip=40.107.22.71 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="QWpMXuUK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OFUYqH3mBM+DcyEyoW+ZYtL0GynlPlrzGSeL/k8F8vk+OQcEjtOPyA2oxWcTkt/CbdF8bFBOWSSXbQO7b1NL6GUAFVKZqYpNJtjNcHQTGswDYdQiORiWqbkklW49YhyRVClrHLQt3yRZikVm+Un/25/t00bFTa47KCwzhk21TFjHqZlvkrc/0VhK5VLrOo9jO065n0KzzOeMpmJFNw9MUm9nTOZTqOwpEE5WIOASIgHPF409ZvTOg9DxrGcnFcOD4EasQsUfluB/5iGqPJO5rsQii//qukzrDQD/VXb15qlbTcfuGmzBn5HPa5NYh5fMS0wg1ryizbxTawSeqM+0dg== 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=HHMyZf9+ayDIm4synsZigKkrfzfndHjFxYve1EM9LII=; b=VYJCIf5/I+HczGAbS5WbS5Hyf747YasrC1b7KVDosYK9ophN7G4JUFSt8xM8NYI2HdvcFMshs515RJsl39XQsTTsb5qcMPVTKB6iQgcNWZmIDTsbkkE97OOsulTKhDunTjIdF+AHnCDLYewaYooJPnu2viX1oTz3VA0JSqLEqCeDipGFbuk7HRcLpVaw/Cu9iARKMzn+oasyBrN/s/yfGWWmVKfumZ3MRbsAH8q25fB55Or+SplLxtQEWu9EXTVO81k9I0OvnZJcgmfCKdhznTpvkSfmCYcjb709tWHpYejQNB9Ixbm4RJW9Drs/smvGNAB4sV6o9uJ9WJh2XAdNvg== 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=HHMyZf9+ayDIm4synsZigKkrfzfndHjFxYve1EM9LII=; b=QWpMXuUKixMgeDPQr/NZDULruoPJR+KrLB+XOlRWkLpSSbFvnvD2aiU9igM/8UlvPZA40XOqPP9I3JCqWt7AViVBIGi2tXoFG5kq8yWIlLDSG5EZggqik3i2GO0NSYYh4NbeG0VB3YSqUDLq5IXI4mzfE/oMveH4tl25us5v/TtxRT1Bj1IcZpWFDW38X/jAjGppmoMgXYgEHHpx29OK7Zfn93lEbBxNYxV3AVQ9SbsT3dVMh9y6lBbxh24AIoEw+Jjb1Q8vG5qTV2POpyrGBeQvu4bzeXL9DyuGLgB/zvsrX/d+lhb+z0YwAg3LuzSS+Nqscb8E9VEtallB90c69w== 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 DB9PR04MB8395.eurprd04.prod.outlook.com (2603:10a6:10:247::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.33; Thu, 8 May 2025 19:48:43 +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 19:48:43 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: =?utf-8?q?K=C3=B6ry_Maincent?= , Andrew Lunn , Siddharth Vadapalli , Roger Quadros , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Richard Cochran , Russell King , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH net-next 2/3] net: cpsw: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set() Date: Thu, 8 May 2025 22:48:24 +0300 Message-ID: <20250508194825.3058929-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250508194825.3058929-1-vladimir.oltean@nxp.com> References: <20250508194825.3058929-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0471.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7f::10) To AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) Precedence: bulk X-Mailing-List: linux-omap@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM8PR04MB7779:EE_|DB9PR04MB8395:EE_ X-MS-Office365-Filtering-Correlation-Id: 59518639-4e62-444b-abcb-08dd8e69566f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: UO4pptSeC5VGPdjZtvefizVhyW+eEMosmKTEmWNFU2yNg594aE6tv+uduCsE32t4S0nuy4eWnvLTRaX/f39PpRJLO94mmTgYGUxcjsw2QhlVPVHT/ZQai5iWgwDjIIepCt7pN/kP2ycaYZLzk+ocrgJs+flwxYIrVxv9SXkG0/b2CLdNhmPM+7c9QZS3n6G8tD/pC7HLXIIHCF/jh2szQew7HVWutWEMX6CuKXSAqEMsK0tfPLj6xViqXa0k4MssVUxAZQDjQHLh/Aiuou8doGYWak5gBG6l+vVZvCtiWYfTqLUy5SCMngBIurbdt0svkqwgNWLua1uf/5pFp/VJup57o9GXPcClswikT0JhVX0FW7wUg4rgFjhah3xVgrOQNEiPoPuuBGqnitvSpXFbLirjQeQZxYrqRRJEPWJ4MkzO+IqHhasbdm72FiBNFpC8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en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR04MB7779.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(7416014)(52116014)(376014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: W0dD6Obe8kon/CPt+SIdBdhsGE+ZSo1DKm42w1/O7kNQZw5sMsT9cKRfaID6KmEyuo4rPbl2E42aR/L9XXijgnvccke2cvKfdSjgPOTpiw8+UvXJZMonBBrcALoliQqa51cN8nP9jhk/uw5xIREa1IVo5l+PzApNlz42e4mjverrtXny5gpXTS21+lq2VIe/yP53goMQG+wbTnQF8furrQ0VrxcLzzXwK2nHUSfI6+t5hYQJk2pLSxwxfkFyRxeVSKL1zhVvTA7TvyAW98tpDYz7RZ2g8gy/3eYQqVFNr0OoEzQq0MFEvvd1629OCUQeP92QA6nOxOqHDyYxXSUCWkNdnD5Veu2+Wh5GR/vLftMCn4UQc+bSvrW2Qvo4HpvC7Lm4eXyt5Mhwd14bxzNyG3pVqbldKLqdgabt9ki0TXWEm+akmEq51SP+wobIpELAYmiNOjvbdscSNlGuwdOCidhhpK2RmUiU1v5y/Bz652J5CBO7L6B1W3DNcfrWnYCUSWax9EOrMmauN3JfOb005IMA7PREITkhV22Ux3ypMnvK9S6y5vhBvABPnYMjdoYXOyViu6vBXmkBctnHYGnrmy4/FRUBwkH0lMnE9ayzEN1ToYfEgQI/QSc2qQjn47qeeLaHTFAveoWKeHGtLpYFP8eVpDhw49I32CrtyEC6pef752nT6cYdzQfwl6a5zPcrZpLTK/6xl/RYY0+KpLDGaT8n5yZMN+xcQv4WLW2cfHJ8LO5N2T6eVgtqPYeYiRqrFUjCjSnRYkCyQagwHcCv5q4E7LL7T4YUZ1SEDnSbgj/dcJqrs2PlXpgbcT7HWnQI1vT3mk2FYBg6TsRShGtsJ1oBf53m5EKwsexQeM2RIQgFwC/g0ABF0XeOrhtJNmVDtNHqhcIz3mEb+y0BrR5w+BmP2NkbfZS64+09mxlKlC/U3cft4Kch8nk23aTGP2giYfQspC2trUOUETD4NdiRC4aEqbUZP3PAm4hvRcZ+a9hfbdwNZKPfZnbAQ98PM4H24Z66XR7mjg/C/ZHzi6T6SO4MnuT80lTz21PV0SZnuOI8IVcAVRBzgX3NitIbFa4JXalewWSbTznArZnvM2mwNRgWC494NfT0cBY87K+YdW6KHmuRuclDu9eoIA0DYVM41SYFJ0/ii0YT/uNclTU2qzOeHc/B1XKdEzac2dt5474AgCeh7dgVM0VPTDXbGDnPy5f0HbZiAEmzXVzGboQlgRl8cJcYneJn3ihOPOEj2/oqq+V37nznSBa0PPDkIhXMXkvFK+ETKZIC8euoEcdif36N7Y0pdr85Oq8KcLhFIwEYEA4BeQhAqPf3ti+Y8TeERNz9gskGhn7KPSr0BFPrIXS0I1m+tErbfdT5Pz/86PzHJvkgC/GACkQNUWlMmvGCavK0H1JpXVWE5cbmRwdarJwSThS0OJxarwvu1PN/d4/j7KHQ3VShVOExz2lAnKqICf2ngObFd+Ujgs1/qqCArpGDPVOEUA9HpHV8p/pop4+NZehm+JNKYmmuUkHssDOW6TKB5rrPqRmvxw8N0uGnMl3mTeYai4hf9n5DBGU7D+nwrX1Y/5Ivx4Bn6GT2CNiFhBIpCcwgDq5fcixIFHhRIQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59518639-4e62-444b-abcb-08dd8e69566f X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2025 19:48:43.0796 (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: GppVc9eYZrUO2JjZVRFGdRNYyuuyzIlw0tuvD9AZSufTT+G6ZB+CDkKWGV+iEKT1vbjrh8ObrpAM98eA7HHiDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8395 New timestamping API was introduced in commit 66f7223039c0 ("net: add NDOs for configuring hardware timestamping") from kernel v6.6. It is time to convert the cpsw driver to the new API, so that the ndo_eth_ioctl() path can be removed completely. The cpsw_hwtstamp_get() and cpsw_hwtstamp_set() methods (and their shim definitions, for the case where CONFIG_TI_CPTS is not enabled) must have their prototypes adjusted. These methods are used by two drivers (cpsw and cpsw_new), with vastly different configurations: - cpsw has two operating modes: - "dual EMAC" - enabled through the "dual_emac" device tree property - creates one net_device per EMAC / slave interface (but there is no bridging offload) - "switch mode" - default - there is a single net_device, with two EMACs/slaves behind it (and switching between them happens unbeknownst to the network stack). - cpsw_new always registers one net_device for each EMAC which doesn't have status = "disabled". In terms of switching, it has two modes: - "dual EMAC": default, no switching between ports, no switchdev offload. - "switch mode": enabled through the "switch_mode" devlink parameter, offloads the Linux bridge through switchdev Essentially, in 3 out of 4 operating modes, there is a bijective relation between the net_device and the slave. Timestamping can thus be configured on individual slaves. But in the "switch mode" of the cpsw driver, ndo_eth_ioctl() targets a single slave, designated using the "active_slave" device tree property. To deal with these different cases, the common portion of the drivers, cpsw_priv.c, has the cpsw_slave_index() function pointer, set to separate, identically named cpsw_slave_index_priv() by the 2 drivers. This is all relevant because cpsw_ndo_ioctl() has the old-style phy_has_hwtstamp() logic which lets the PHY handle the timestamping ioctls. Normally, that logic should be obsoleted by the more complex logic in the core, which permits dynamically selecting the timestamp provider - see dev_set_hwtstamp_phylib(). But I have doubts as to how this works for the "switch mode" of the dual EMAC driver, because the core logic only engages if the PHY is visible through ndev->phydev (this is set by phy_attach_direct()). In cpsw.c, we have: cpsw_ndo_open() -> for_each_slave(priv, cpsw_slave_open, priv); // continues on errors -> of_phy_connect() -> phy_connect_direct() -> phy_attach_direct() OR -> phy_connect() -> phy_connect_direct() -> phy_attach_direct() The problem for "switch mode" is that the behavior of phy_attach_direct() called twice in a row for the same net_device (once for each slave) is probably undefined. For sure it will overwrite dev->phydev. I don't see any explicit error checks for this case, and even if there were, the for_each_slave() call makes them non-fatal to cpsw_ndo_open() anyway. I have no idea what is the extent to which this provides a usable result, but the point is: only the last attached PHY will be visible in dev->phydev, and this may well be a different PHY than cpsw->slaves[slave_no].phy for the "active_slave". In dual EMAC mode, as well as in cpsw_new, this should not be a problem. I don't know whether PHY timestamping is a use case for the cpsw "switch mode" as well, and I hope that there isn't, because for the sake of simplicity, I've decided to deliberately break that functionality, by refusing all PHY timestamping. Keeping it would mean blocking the old API from ever being removed. In the new dev_set_hwtstamp_phylib() API, it is not possible to operate on a phylib PHY other than dev->phydev, and I would very much prefer not adding that much complexity for bizarre driver decisions. Final point about the cpsw_hwtstamp_get() conversion: we don't need to propagate the unnecessary "config.flags = 0;", because dev_get_hwtstamp() provides a zero-initialized struct kernel_hwtstamp_config. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/ti/cpsw.c | 5 +++ drivers/net/ethernet/ti/cpsw_new.c | 2 ++ drivers/net/ethernet/ti/cpsw_priv.c | 55 ++++++++++++++--------------- drivers/net/ethernet/ti/cpsw_priv.h | 5 +++ 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index a984b7d84e5e..b71352689768 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -1174,6 +1174,8 @@ static const struct net_device_ops cpsw_netdev_ops = { .ndo_setup_tc = cpsw_ndo_setup_tc, .ndo_bpf = cpsw_ndo_bpf, .ndo_xdp_xmit = cpsw_ndo_xdp_xmit, + .ndo_hwtstamp_get = cpsw_hwtstamp_get, + .ndo_hwtstamp_set = cpsw_hwtstamp_set, }; static void cpsw_get_drvinfo(struct net_device *ndev, @@ -1646,6 +1648,9 @@ static int cpsw_probe(struct platform_device *pdev) ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_CTAG_RX; ndev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | NETDEV_XDP_ACT_NDO_XMIT; + /* Hijack PHY timestamping requests in order to block them */ + if (!cpsw->data.dual_emac) + ndev->see_all_hwtstamp_requests = true; ndev->netdev_ops = &cpsw_netdev_ops; ndev->ethtool_ops = &cpsw_ethtool_ops; diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c index 5b5b52e4e7a7..f5b74d066f0e 100644 --- a/drivers/net/ethernet/ti/cpsw_new.c +++ b/drivers/net/ethernet/ti/cpsw_new.c @@ -1147,6 +1147,8 @@ static const struct net_device_ops cpsw_netdev_ops = { .ndo_bpf = cpsw_ndo_bpf, .ndo_xdp_xmit = cpsw_ndo_xdp_xmit, .ndo_get_port_parent_id = cpsw_get_port_parent_id, + .ndo_hwtstamp_get = cpsw_hwtstamp_get, + .ndo_hwtstamp_set = cpsw_hwtstamp_set, }; static void cpsw_get_drvinfo(struct net_device *ndev, diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c index 68d8f7ea0e44..87e40f2dca45 100644 --- a/drivers/net/ethernet/ti/cpsw_priv.c +++ b/drivers/net/ethernet/ti/cpsw_priv.c @@ -614,24 +614,29 @@ static void cpsw_hwtstamp_v2(struct cpsw_priv *priv) writel_relaxed(ETH_P_8021Q, &cpsw->regs->vlan_ltype); } -static int cpsw_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) +int cpsw_hwtstamp_set(struct net_device *dev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) { struct cpsw_priv *priv = netdev_priv(dev); struct cpsw_common *cpsw = priv->cpsw; - struct hwtstamp_config cfg; + + /* This will only execute if dev->see_all_hwtstamp_requests is set */ + if (cfg->source == HWTSTAMP_SOURCE_PHYLIB) { + NL_SET_ERR_MSG_MOD(extack, + "PHY timestamping only possible in dual EMAC mode"); + return -EOPNOTSUPP; + } if (cpsw->version != CPSW_VERSION_1 && cpsw->version != CPSW_VERSION_2 && cpsw->version != CPSW_VERSION_3) return -EOPNOTSUPP; - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) - return -EFAULT; - - if (cfg.tx_type != HWTSTAMP_TX_OFF && cfg.tx_type != HWTSTAMP_TX_ON) + if (cfg->tx_type != HWTSTAMP_TX_OFF && cfg->tx_type != HWTSTAMP_TX_ON) return -ERANGE; - switch (cfg.rx_filter) { + switch (cfg->rx_filter) { case HWTSTAMP_FILTER_NONE: priv->rx_ts_enabled = 0; break; @@ -651,13 +656,13 @@ static int cpsw_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) case HWTSTAMP_FILTER_PTP_V2_SYNC: case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: priv->rx_ts_enabled = HWTSTAMP_FILTER_PTP_V2_EVENT; - cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; + cfg->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; break; default: return -ERANGE; } - priv->tx_ts_enabled = cfg.tx_type == HWTSTAMP_TX_ON; + priv->tx_ts_enabled = cfg->tx_type == HWTSTAMP_TX_ON; switch (cpsw->version) { case CPSW_VERSION_1: @@ -671,34 +676,36 @@ static int cpsw_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) WARN_ON(1); } - return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; + return 0; } -static int cpsw_hwtstamp_get(struct net_device *dev, struct ifreq *ifr) +int cpsw_hwtstamp_get(struct net_device *dev, + struct kernel_hwtstamp_config *cfg) { struct cpsw_common *cpsw = ndev_to_cpsw(dev); struct cpsw_priv *priv = netdev_priv(dev); - struct hwtstamp_config cfg; if (cpsw->version != CPSW_VERSION_1 && cpsw->version != CPSW_VERSION_2 && cpsw->version != CPSW_VERSION_3) return -EOPNOTSUPP; - cfg.flags = 0; - cfg.tx_type = priv->tx_ts_enabled ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; - cfg.rx_filter = priv->rx_ts_enabled ? HWTSTAMP_FILTER_PTP_V2_EVENT : - HWTSTAMP_FILTER_NONE; + cfg->tx_type = priv->tx_ts_enabled ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; + cfg->rx_filter = priv->rx_ts_enabled ? HWTSTAMP_FILTER_PTP_V2_EVENT : + HWTSTAMP_FILTER_NONE; - return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; + return 0; } #else -static int cpsw_hwtstamp_get(struct net_device *dev, struct ifreq *ifr) +int cpsw_hwtstamp_get(struct net_device *dev, + struct kernel_hwtstamp_config *cfg) { return -EOPNOTSUPP; } -static int cpsw_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) +int cpsw_hwtstamp_set(struct net_device *dev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) { return -EOPNOTSUPP; } @@ -715,16 +722,6 @@ int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd) return -EINVAL; phy = cpsw->slaves[slave_no].phy; - - if (!phy_has_hwtstamp(phy)) { - switch (cmd) { - case SIOCSHWTSTAMP: - return cpsw_hwtstamp_set(dev, req); - case SIOCGHWTSTAMP: - return cpsw_hwtstamp_get(dev, req); - } - } - if (phy) return phy_mii_ioctl(phy, req, cmd); diff --git a/drivers/net/ethernet/ti/cpsw_priv.h b/drivers/net/ethernet/ti/cpsw_priv.h index f2fc55d9295d..b23f98032669 100644 --- a/drivers/net/ethernet/ti/cpsw_priv.h +++ b/drivers/net/ethernet/ti/cpsw_priv.h @@ -469,6 +469,11 @@ bool cpsw_shp_is_off(struct cpsw_priv *priv); void cpsw_cbs_resume(struct cpsw_slave *slave, struct cpsw_priv *priv); void cpsw_mqprio_resume(struct cpsw_slave *slave, struct cpsw_priv *priv); void cpsw_qos_clsflower_resume(struct cpsw_priv *priv); +int cpsw_hwtstamp_get(struct net_device *dev, + struct kernel_hwtstamp_config *cfg); +int cpsw_hwtstamp_set(struct net_device *dev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack); /* ethtool */ u32 cpsw_get_msglevel(struct net_device *ndev); From patchwork Thu May 8 19:48:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 889307 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) (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 1ACC628C2CE; Thu, 8 May 2025 19:48:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746733737; cv=fail; b=MUU43aXmWHvwT33Tz/qs9KKIYfRJ2PpSlOH0Q63xWXeN8BdnGozQyq07FYKphd8wAFFUGE3ICvENBQwEXY3kLByAK2I86D1KS9goB/CfT07Fh+R1tG+SE+qbFOtgeyhb1VD/D3uAl5JcLOtJC0bqxqj0R/O3l5afj3ttMDd5VpA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746733737; c=relaxed/simple; bh=cw19VX1A9LWU5sXP2ukgme05I8N+4Z/IueYFd9n6HlI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=K37mu0nf1KmWYtYTKsigAoesSbnfcnwr0YUh3UEAXck4uQ2yChNu0nhaMritNcHuBOr7wsfkYl+7a+mqX/4l+U4DM7upXaWkMS3j2lufSklm9rTM0+UdphAc8e5AF2zzcS4IZFOjUu0m3jwJcgnW/URIloxoQM0eiOvWKxct5JE= 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=MhOripCI; arc=fail smtp.client-ip=40.107.22.71 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="MhOripCI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YR03NVVpRs/lHyulnlijmbZHIuTFvPBcbIXALjteomxevO7lPNslG9QO+THPVxU6rkNDMSYkV6cu0yJhne69N+WEjJzgh3/DTll7hpkgyCZAiHc30FvvkkEOurtcws5AdY6uWzq/zJQ250/2fPxmmSQyF43KK62dlw9xl3C4S9o89X9xXoqqhtl4hEH8tt8BA5fMHAy45FXvlMnfRbgVSXa/M/Ur23vQDGYKx52S8PPeZbbDgKlOFRNqaWzVxeS14iTOkCNXRnUNCoewBFt0vTxRaYz5MqxXUIYLti2MlXqvxGU62Fd0EplYNZZVK7f4dg4eIN3CbqHKMgrTeoh3/w== 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=Uswb5IvXwS/R3Q3uP+Xx5CX4aMzrpODsiXq7E2+bOaU=; b=Vqd7UXuhwR8rMPiZnCTZO5ffhTWpwyjYfVgoEdbslqsyeQpiQe5TCKqFkuktVgi3PHY1tuv2eR35+NkmxxJuUbDJs1oK8QzXMiY6ZGjB6yaJxh1IvVhCV+x51sNKaHiO3jRmHQiwnaFLVIGhkVWrGeXyvp58t5KkmyvLGEQnGjhgmIi6F0kubzpHAESWWIVhBAx00rTNyWx5wnE7R+II5VotDyA1ySCbRylJnNJKJ6uGfWEHX7b4iB9MsrcZBs+zY//TVSQt7bVEKSThyoGcdEPHlCRJZtQB7xeOID+FZkqo38SixGLCXHbDtOdTmrS2luSUcBcoVvWznyu2SCc7BQ== 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=Uswb5IvXwS/R3Q3uP+Xx5CX4aMzrpODsiXq7E2+bOaU=; b=MhOripCI0XQE8UrWwsoLa90YrrbuFZ6eKai7mLte9FLsFY2Lgz6kloukI2Qnn8i27H0YKfyHRiBig2V/AZK8v+V6HmZktnjbgZypqSr5z+JwypPKlMyDyeHenn3N7z0IZBDBkgF8cM4UmCcPWI3kbD6bPkM7y95xSNqe+kRyol3kBJQIJpq/qOLvZaKFlm7hEnVUH/9nJS9P2We+Qb/FwuqL7rmcwYL7LO7wxDMT15eL4RLZ6hm+Boa02PgMtOVUUs5E1JBKdpmnkHWMvvglEwidexW82PlZWy5fy8YFXmLL4/E2YdohWG749qaDXj9qJ0NmTYpm4qMD0MhbuI+ynQ== 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 DB9PR04MB8395.eurprd04.prod.outlook.com (2603:10a6:10:247::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.33; Thu, 8 May 2025 19:48:44 +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 19:48:44 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: =?utf-8?q?K=C3=B6ry_Maincent?= , Andrew Lunn , Siddharth Vadapalli , Roger Quadros , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Richard Cochran , Russell King , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH net-next 3/3] net: cpsw: isolate cpsw_ndo_ioctl() to just the old driver Date: Thu, 8 May 2025 22:48:25 +0300 Message-ID: <20250508194825.3058929-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250508194825.3058929-1-vladimir.oltean@nxp.com> References: <20250508194825.3058929-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0471.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7f::10) To AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) Precedence: bulk X-Mailing-List: linux-omap@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM8PR04MB7779:EE_|DB9PR04MB8395:EE_ X-MS-Office365-Filtering-Correlation-Id: fcf6446a-33e1-431c-5f6f-08dd8e695709 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: s5ty91peLUasjpfm8VzLkI974JZZ1FbZBvBAQi05vSQ1cMjX5HPFAq3QmoaETvvO6iHtHlZ8t1BkRobwRCFkFcxSvh21Q8C11PNSQ+AdVmuTraYA1ht9bIfL83H2XrfhPktNgsrA/7b2sncVdLi6Y1PsrVPmI1HGP2Ncx0g1L+ImAq82GoPRGlP30odhFJmwwrkN8KtR7SYndS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+Y+928hEKO9eonLRo3goKHkd8oGK74blQ3oL37UcP1s5c/ZOG8EWPeLYu5ZRODeca0050MZ87UM7+2ClKIKXh9z/eOQYXpnvUd1mtm/MSfUFG5gMoBlUYxShEzIGlGEw8WzxKsTxNIEg9oTyDNDd2eCe/2hxCJv38SFbouLLZtctL/xXmU6IxKiNNMdMHbAlLQnVC3/YKkRCIILd+EwbrgF9Or+GWbFg== 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)(7416014)(52116014)(376014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JG+veOtZrLU3dt3legJqc2f4bTVnlaWuODy/2lK/Wg9uOdkqzlQm02R6rF/jpWScAdRaocbFoIt+et5xu6umQnyXkN0p9kvB5A+LnoePR9hAt917ue70YchlR1+CoQd4o/HBvsjPBnQJqR/7KpLbyI7Hewvh2s3HOCAeaGLWLjs56ahv/uzXyW382VA5aEMHLOAMD4UTryUY/65fRedcS2UOr7LnMCVwBdBZ3m15zGv/rOy/N6vbQUli3rKKRHAfJBToZQ1yPGYMLj1XQ8xk901OkWFwQSio0R0KplTAUnu6HPe7bSVJce2zpzwElTiHYy/pPduiqc8Vc3Zd2LumjmGn5q5itlmvMhP4igY5UKv0hAb2dr7TAUd8pgpNPcHpS7m9k1RwbR4oYktZLbHCgrS4DQBojkw+r2yrDMlGWt8yfuBLz60RKv9DhbW1JpZlZkpGZSz9gMIEIj49d5HsrsH3e3n4VI4HSCIZXoqXNGZD9BWEHmH+0v3G1N7+U9A+S4WPWYiYUC12gBEt8fPvStlsa/3gajOq+aRrHdpu+jrEifaupBDPw5c4NfNC1FAGT/5ulafhlAW1GvYDijPvhYaefAFSQ3TB14ugz48sGFwhaL70HzRkwhEdZ73vFox0loXHL4mbqlRUeoAkVFSleaWjSpcLUfezcLchS7Hqr/1TLwMRXueHCvkvqbyv8xdl26d4mVtt9SOshl7WRQB1SN6epSJvb7+SQk6zFUF/2dm/+6JP9cZN84CkGJI5Jl8nOZqZ1PaFxbbvmavkazG86sTp5tnGrNnH7PBrFKCdERwZhcO0D3tXTwXJB3NUDjg/vBOa1p5R+n2IiC91gMsOlHDtMcEfsu5FETPFEYkNZm1Hcr3Z4Yf/xsx9QVtGvOisZzu2nvQVFSCzSLzC+z6YIujCtoEUKYuaxfOq8SJs8hcSBPMULGp/M/GCACsvc5CY9Vf3Ry/Iz1ddKgG9OA58UMsINWem1FkMoCOieRcuapa+PS+tVdSd6h4hev2SikjUKnW+76QXRUt8MSp9nkarzToeknw3Rz/i6NOHKftbdA2oJsmh9vzktpsUCAc273PhC8nltaeiT7GacJ9eHSj2t6BTipVXsYVG6Pz+mLbSt6STzeraU0UQfiDEv527esmT74aLDRaPxOa5tqyXsMIEd6Z0466QnWEYCSwCo72o9USS6vnRHZRIYrstSeIh/r6BLgAm7C4D29w/E9Y4kPF58cJpgyLV9rcsakBP/b7eFvTMs83J+ewoK1dS8qSL3UGr1fFJzw/ddl6zrckylOzTyPjEIq88cpKrMsRAOX+eyBtinl30n14cZHsriACW61nqqsRiIhOqGlr/rTk3uG57zImz8zTYMr98AYOI+r8SZSTgy//QAuOMCNH7GI3vBZaP5++XV0hGpqM/4kB7TzqPGgOkXqe9zxjSyPEWj6HvWl2qP4U3KV8vXEqJE4kCYruuO/4YPhWr6e8G244O8FeoRYGydFWKR8HGfclPQctFGQMXCZnpqBkq58bvfsm9A612PRb6ue7YPKCUFf5iGoxhnj5s/1CHLxF5TOKXBE79MzZi8EKE21pQmyano8Q45evFVnFe3oisTr+qTX+C4QvZzw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fcf6446a-33e1-431c-5f6f-08dd8e695709 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2025 19:48:44.0739 (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: HkEn3n+D3Dn0hjxUoOyqGkPpIVgQIDWv6UXio2nkw+fOStP7sCuYEXhy4TTnsr6nqx70itRS99Af/oA7a3nBAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8395 cpsw->slaves[slave_no].phy should be equal to netdev->phydev, because it is assigned from phy_attach_direct(). The latter is indirectly called from the two identically named cpsw_slave_open() functions, one in cpsw.c and another in cpsw_new.c. Thus, the driver should not need custom logic to find the PHY, the core can find it, and phy_do_ioctl_running() achieves exactly that. However, that is only the case for cpsw_new and for the cpsw driver in dual EMAC mode. This is explained in more detail in the previous commit. Thus, allow the simpler core logic to execute for cpsw_new, and move cpsw_ndo_ioctl() to cpsw.c. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/ti/cpsw.c | 20 ++++++++++++++++++++ drivers/net/ethernet/ti/cpsw_new.c | 2 +- drivers/net/ethernet/ti/cpsw_priv.c | 17 ----------------- drivers/net/ethernet/ti/cpsw_priv.h | 1 - 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index b71352689768..b52136db3621 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -1156,6 +1156,26 @@ static void cpsw_ndo_poll_controller(struct net_device *ndev) } #endif +/* We need a custom implementation because in switch mode, dev->phydev may + * be different than the phy of the active_slave. + */ +static int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd) +{ + struct cpsw_priv *priv = netdev_priv(dev); + struct cpsw_common *cpsw = priv->cpsw; + int slave_no = cpsw_slave_index(cpsw, priv); + struct phy_device *phy; + + if (!netif_running(dev)) + return -EINVAL; + + phy = cpsw->slaves[slave_no].phy; + if (phy) + return phy_mii_ioctl(phy, req, cmd); + + return -EOPNOTSUPP; +} + static const struct net_device_ops cpsw_netdev_ops = { .ndo_open = cpsw_ndo_open, .ndo_stop = cpsw_ndo_stop, diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c index f5b74d066f0e..8b9e2078c602 100644 --- a/drivers/net/ethernet/ti/cpsw_new.c +++ b/drivers/net/ethernet/ti/cpsw_new.c @@ -1132,7 +1132,7 @@ static const struct net_device_ops cpsw_netdev_ops = { .ndo_stop = cpsw_ndo_stop, .ndo_start_xmit = cpsw_ndo_start_xmit, .ndo_set_mac_address = cpsw_ndo_set_mac_address, - .ndo_eth_ioctl = cpsw_ndo_ioctl, + .ndo_eth_ioctl = phy_do_ioctl_running, .ndo_validate_addr = eth_validate_addr, .ndo_tx_timeout = cpsw_ndo_tx_timeout, .ndo_set_rx_mode = cpsw_ndo_set_rx_mode, diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c index 87e40f2dca45..4a3cdb9a139e 100644 --- a/drivers/net/ethernet/ti/cpsw_priv.c +++ b/drivers/net/ethernet/ti/cpsw_priv.c @@ -711,23 +711,6 @@ int cpsw_hwtstamp_set(struct net_device *dev, } #endif /*CONFIG_TI_CPTS*/ -int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd) -{ - struct cpsw_priv *priv = netdev_priv(dev); - struct cpsw_common *cpsw = priv->cpsw; - int slave_no = cpsw_slave_index(cpsw, priv); - struct phy_device *phy; - - if (!netif_running(dev)) - return -EINVAL; - - phy = cpsw->slaves[slave_no].phy; - if (phy) - return phy_mii_ioctl(phy, req, cmd); - - return -EOPNOTSUPP; -} - int cpsw_ndo_set_tx_maxrate(struct net_device *ndev, int queue, u32 rate) { struct cpsw_priv *priv = netdev_priv(ndev); diff --git a/drivers/net/ethernet/ti/cpsw_priv.h b/drivers/net/ethernet/ti/cpsw_priv.h index b23f98032669..91add8925e23 100644 --- a/drivers/net/ethernet/ti/cpsw_priv.h +++ b/drivers/net/ethernet/ti/cpsw_priv.h @@ -461,7 +461,6 @@ void soft_reset(const char *module, void __iomem *reg); void cpsw_set_slave_mac(struct cpsw_slave *slave, struct cpsw_priv *priv); void cpsw_ndo_tx_timeout(struct net_device *ndev, unsigned int txqueue); int cpsw_need_resplit(struct cpsw_common *cpsw); -int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd); int cpsw_ndo_set_tx_maxrate(struct net_device *ndev, int queue, u32 rate); int cpsw_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type type, void *type_data);