From patchwork Mon Sep 30 06:36:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lin X-Patchwork-Id: 13815431 X-Patchwork-Delegate: kvalo@adurom.com Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2074.outbound.protection.outlook.com [40.107.21.74]) (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 97B49183CCA; Mon, 30 Sep 2024 06:38:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727678319; cv=fail; b=kA+z+oW+vG7oEIOLHroB7DDJgvzcnSIWk2nkWLPDlp+yxnQc0UaWi6UU91LMKzFPXGiY68BZlnrVPPjoLye9xoX62Vc211uQMpntXnLxBviaQhJQndeDaAei8uad5zTv3bM1+ZgiMHdeDWvCi3fbUX4+Zt/PDf48F7yHIaVb4rE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727678319; c=relaxed/simple; bh=MqXLYPCMV1eqb2mw4jj/tGIok272B1ZFiqy1ovw1R0s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=VewtJMkHosbw9duOie8HBhZF7/N4AhjhOteHk23qzJa0asqQ/MYpKPPp39ktb6qJBJoWC5YenDA3CQUQb5di/qt0YgovC+9KoUOQT4rRPotHG+fuZTNYLHKkQJsq0GMBk76OgAVubaPHjx97GQXgCjO5V83HEyfywznU+fYwSWU= 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=BHXsJF4I; arc=fail smtp.client-ip=40.107.21.74 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="BHXsJF4I" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gn0J+cTyHSvWajHo2QVFQ6UK919qDVPNnGdVASJNkkSla5qYUXUXt6iN5sYWpoBuB3NHiavPRSfD7Ntbg33Bp8xysEJrzPFVifI8aFQKO7JxQ1g8/RusBi4j7nlsNYMzRzZTG4xiyljZ65Fu1p1oqTNnt93ED96l6b7RyIYMjUWu1JhKquDwBNFN5ec+wFDV4EkQo8FfZP85zBVahIg1sNR1SKqKhNyY7OdL33nG1KbdsgzBPQXxICoZAHhjCRnbztLP8W3WrR6Xj+JHkt0nUEjYN5sUTinuZsO5R5XRc8Hj6DXwqiF8uRMRLWOJcmyA155h95Fggb20PthpYbbuhQ== 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=H+b7b3Yp4o7k6ymtI9MtYerGLM1PxttDiaDliLQLklw=; b=HM+XgdLOZjYLuBELKS9jkJaKjuOGJPhc3e1cT9npWIBDHbk1uNLai5LKjxCmqHSRKCCp7YIG3nKamBBMKOh3g9fTqhuNTiFS7h8t5532fbHq9NgeC5r9kGX9mmm1Z/8oTJ2e1pXCuXgN3kdXSLzwmCOs+wWHxEaHjL7Gsr1KmLMn9LEWwM51F9aNgVJTXoZt0OnQ1vI7JUqw+vmXo3M1IAoDwEuusqiKLJBa3/KlcHqo0KCw6QyJ2DQkAFrnNxBTKERrDIh3QEZTFhAaWF0KQqLgkI0vyPL5laE9jOCDDgOGbunO9ahpTdaUxAdzY+6lmGneBUg6WZt2LoClX+8tSQ== 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=H+b7b3Yp4o7k6ymtI9MtYerGLM1PxttDiaDliLQLklw=; b=BHXsJF4Ih7tBHccywHeUI4DHDb40mUFL51aMuXWg42sssu+REa94l8165KH1iF2ZGlasDtSuBl3Egydvb7bBbgxlBH1mya2K41N3kg10fSVbFzG0TMeQ6hFzelkZPFClOPk968dfEAcPG477ryBZDcURCfN6GP5kUxCHOEb6rMCQcdU5BswFqdTzt1eTzpJff5ScPtA04FnsKgQEgLtu0U993bCf4jgLz0xY+eodCytiyshrRqVl0v0jVhBkCc0Dz7o11RIHg1d9ZYsAWXR0L7DANz5ZwzRzG1Szq8zyB6upP/ZYRYzicMRSuGOqBI6f8Jayyk5lmBzEurrdd5Oh+w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PA4PR04MB9638.eurprd04.prod.outlook.com (2603:10a6:102:273::20) by PAXPR04MB9154.eurprd04.prod.outlook.com (2603:10a6:102:22d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.23; Mon, 30 Sep 2024 06:38:15 +0000 Received: from PA4PR04MB9638.eurprd04.prod.outlook.com ([fe80::f950:3bb6:6848:2257]) by PA4PR04MB9638.eurprd04.prod.outlook.com ([fe80::f950:3bb6:6848:2257%3]) with mapi id 15.20.8005.024; Mon, 30 Sep 2024 06:38:15 +0000 From: David Lin To: linux-wireless@vger.kernel.org Cc: linux-kernel@vger.kernel.org, briannorris@chromium.org, kvalo@kernel.org, francesco@dolcini.it, tsung-hsien.hsieh@nxp.com, s.hauer@pengutronix.de, David Lin Subject: [PATCH v3 15/22] wifi: nxpwifi: add ethtool.c Date: Mon, 30 Sep 2024 14:36:54 +0800 Message-Id: <20240930063701.2566520-16-yu-hao.lin@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240930063701.2566520-1-yu-hao.lin@nxp.com> References: <20240930063701.2566520-1-yu-hao.lin@nxp.com> X-ClientProxiedBy: AM8P190CA0001.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::6) To PA4PR04MB9638.eurprd04.prod.outlook.com (2603:10a6:102:273::20) Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PA4PR04MB9638:EE_|PAXPR04MB9154:EE_ X-MS-Office365-Filtering-Correlation-Id: 30926ae4-2491-4d0d-a2eb-08dce11a7613 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: BuQUd5EigYQdIXmEtyVjoY9HGI+CcO5GfC9/Cdcrf69AF5ogqGBMiXA0E1bpuRt5o6Mw4a6lS+qK7m4DicvqGm+3DLHJzAcd/qJEvcdfXJz6ZI5TSCLO9h3RgkIKpsymCTHMQSnb2js3hXL/LG50KuV2/TLRrqxi61netGNXSmMxY7W3tqfB/rB+5zvLSQRtMZWV3v4sioyk34AO4r+GPCQgIHddQ8Pk4nwT5rKROS6DbVn9Z3LL+vFvGyKPZoxIXm5gzNeZMJ1pTefEChN8tQ3aD7YvV+BPxbzIVhVZ26Z7Yy4to/dwlq6tchdB8DyaTI1qB5JjRGfhu7SplB/WXkM2qkTggFQlogmDbdTioM3XBC8vOydwtUdReFOJD7jUX9sZx0G3Ivw48gTl5cNkzrBcvau809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NLI;SFV:NSPM;H:PA4PR04MB9638.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(376014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xtO8/xJ0Lqkgs6YqHS1bK/gL4XBoyTC0eRIPtve7rtBqSfBzjV6cYfGfzkWGQx17+CSqgbq1kp9CyLE7Fx1HsHkiwOJa3q6wT07juABIfKYbnAcYezRu3NyQ3uyFEHHM2EKBImBOQbyBJXsRov+mXb1zJtg3kzp5J+GWqLryEFDeGeOt98zrOUkzhV6GxVCzsVoIZQbf5Tn3t1ZbM/yMWqBxs5j9QNA8WptVkoqR7doU5bisibK8FoAgpbCgq8KKZR/fOJ5hNA+EMWoqqBEd5eikcZ/HhWhDipYvxtQc+6XGP8IdJvS+f9dXB2SvM7veiOhMvCvtk5xbteMM/0rF+il3RcOidrBIFq+75vWzV3CGQp5hyAEBpVboQ23OCEANoX06mADtqpkAAQn5tbaMpE9SO96YCW7dv7f7Wf29KoVdImNnZDKa2BHBys8+SrHwePi5I+INyQipYzrZ89qXzM18IaZHkFuAk4jF81fY3Z7uc/MIKpIXai/CwVf0l2tsOnJz4gb/k6WrxywZS0buYnAmlk983isd9UKeHnpEEspSpbd8kKQ9FED39g8fnhyBwen2iGPjcy2UcxFGZDh0vVE3C+rzP21kXRzQDhGtGrsqB/+H7lmQNZVPSFGtNXK08wIpgah5SVdMUtvaebK3Mg5EmPtXoAy8+H9EW3+LyWS/5eHsgkrHBRbPOzI0J1AWqYuJmUUJ4l648k34NSEP8GuG3Fjdjxb1kzD/XjNt4R5J/WQ3Plrjef3VuYX22gmpVA3rQXS/3H1iZQeJlmpEOxkVw0l9/Ua9qkzx5sUHrVN5zVX7JvPvu6g/ynzwas1T59lawlKa7xvzk1O92KkPSrK8PgvSeiXhXUNcS45PlexEgg4pwnDxBBlSvoU0AKnj3P+MofXUN0TImVZNKnWaPCwcTNM9trMDXy1byejZF1K7FMBX3wG1YYEaNc6rkfc/WJWKBZnVzXm6m8b96hpASVOkmeZatHWqXrJea5hCtZwZtl2rDWqg6M6wCYE67st3ryLZ57OjWszgAZddMpBWu0jP1kbw/SEadsUSDy+HbPy8QJmpKad0dyB5jSc33Dz30s6d8C1SFwDGUuq3mh4q+ZNUPaYvxX37Rif3CWYVwfLu3C+ccrxcZXYEhzvTN3ZDTuqdE6dOz7GRzyYmSI/zYKqH+MLPOKSoEcC25sioKwdk5fzFcJMRGwbQrz1fZmgh00BAp9rcJsPT0oRP4k4/wXBibnCGHk7s75+/lnlgFGq9inLMIf6vr9qeZTY21IoVVFEEF9IIf77k/NtY2X1GNIhGUxhc/vIn039Gu9fyLx9O/vqOk/TXOlbAnm3iauxUNpQFtV4pZoiSLjlfIcSx8rlAgkmBF9G4YlYO8VWQYkG75YdPvyfbrNA7GNvv7HKR/N4GJwwqy3+SJF0kvW2cDprGimTOfjJv8+A2gFavvAV9cASrcfFLpKCfCwuWkiB9dbnCjLUScUnyK7SmYN+/vftZjlr3ZGrD0TfWR2+g7obXv8xpi/0oCJApDKwon7bXua69dgzrocVgSCnqldMwfFK/8K2V0Z5HYftIjWB1GoQ3+jKYFPB6jRtVWDZAg825 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30926ae4-2491-4d0d-a2eb-08dce11a7613 X-MS-Exchange-CrossTenant-AuthSource: PA4PR04MB9638.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 06:38:14.9584 (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: ntZYngbPOE1+aXGHfiWcyZVFPxCHxFqvgQzWjUS537jZMAmiNv4OmvH0SPKTP7Gb4WQWHr7nqId1980O348NMQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9154 Implement functions related to Wake-on-Lan. Signed-off-by: David Lin --- drivers/net/wireless/nxp/nxpwifi/ethtool.c | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 drivers/net/wireless/nxp/nxpwifi/ethtool.c diff --git a/drivers/net/wireless/nxp/nxpwifi/ethtool.c b/drivers/net/wireless/nxp/nxpwifi/ethtool.c new file mode 100644 index 000000000000..6cefa6e6f5b3 --- /dev/null +++ b/drivers/net/wireless/nxp/nxpwifi/ethtool.c @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * NXP Wireless LAN device driver: ethtool + * + * Copyright 2011-2024 NXP + */ + +#include "main.h" + +static void nxpwifi_ethtool_get_wol(struct net_device *dev, + struct ethtool_wolinfo *wol) +{ + struct nxpwifi_private *priv = nxpwifi_netdev_get_priv(dev); + u32 conditions = le32_to_cpu(priv->adapter->hs_cfg.conditions); + + wol->supported = WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | WAKE_PHY; + + if (conditions == HS_CFG_COND_DEF) + return; + + if (conditions & HS_CFG_COND_UNICAST_DATA) + wol->wolopts |= WAKE_UCAST; + if (conditions & HS_CFG_COND_MULTICAST_DATA) + wol->wolopts |= WAKE_MCAST; + if (conditions & HS_CFG_COND_BROADCAST_DATA) + wol->wolopts |= WAKE_BCAST; + if (conditions & HS_CFG_COND_MAC_EVENT) + wol->wolopts |= WAKE_PHY; +} + +static int nxpwifi_ethtool_set_wol(struct net_device *dev, + struct ethtool_wolinfo *wol) +{ + struct nxpwifi_private *priv = nxpwifi_netdev_get_priv(dev); + u32 conditions = 0; + + if (wol->wolopts & ~(WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | WAKE_PHY)) + return -EOPNOTSUPP; + + if (wol->wolopts & WAKE_UCAST) + conditions |= HS_CFG_COND_UNICAST_DATA; + if (wol->wolopts & WAKE_MCAST) + conditions |= HS_CFG_COND_MULTICAST_DATA; + if (wol->wolopts & WAKE_BCAST) + conditions |= HS_CFG_COND_BROADCAST_DATA; + if (wol->wolopts & WAKE_PHY) + conditions |= HS_CFG_COND_MAC_EVENT; + if (wol->wolopts == 0) + conditions |= HS_CFG_COND_DEF; + priv->adapter->hs_cfg.conditions = cpu_to_le32(conditions); + + return 0; +} + +const struct ethtool_ops nxpwifi_ethtool_ops = { + .get_wol = nxpwifi_ethtool_get_wol, + .set_wol = nxpwifi_ethtool_set_wol, +};