hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/net/wireless/ath/wil6210/ethtool.c
....@@ -1,18 +1,7 @@
1
+// SPDX-License-Identifier: ISC
12 /*
23 * Copyright (c) 2014,2017 Qualcomm Atheros, Inc.
34 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
4
- *
5
- * Permission to use, copy, modify, and/or distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
8
- *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
165 */
176
187 #include <linux/etherdevice.h>
....@@ -22,26 +11,6 @@
2211
2312 #include "wil6210.h"
2413
25
-static int wil_ethtoolops_begin(struct net_device *ndev)
26
-{
27
- struct wil6210_priv *wil = ndev_to_wil(ndev);
28
-
29
- mutex_lock(&wil->mutex);
30
-
31
- wil_dbg_misc(wil, "ethtoolops_begin\n");
32
-
33
- return 0;
34
-}
35
-
36
-static void wil_ethtoolops_complete(struct net_device *ndev)
37
-{
38
- struct wil6210_priv *wil = ndev_to_wil(ndev);
39
-
40
- wil_dbg_misc(wil, "ethtoolops_complete\n");
41
-
42
- mutex_unlock(&wil->mutex);
43
-}
44
-
4514 static int wil_ethtoolops_get_coalesce(struct net_device *ndev,
4615 struct ethtool_coalesce *cp)
4716 {
....@@ -50,11 +19,12 @@
5019 u32 rx_itr_en, rx_itr_val = 0;
5120 int ret;
5221
22
+ mutex_lock(&wil->mutex);
5323 wil_dbg_misc(wil, "ethtoolops_get_coalesce\n");
5424
5525 ret = wil_pm_runtime_get(wil);
5626 if (ret < 0)
57
- return ret;
27
+ goto out;
5828
5929 tx_itr_en = wil_r(wil, RGF_DMA_ITR_TX_CNT_CTL);
6030 if (tx_itr_en & BIT_DMA_ITR_TX_CNT_CTL_EN)
....@@ -68,7 +38,11 @@
6838
6939 cp->tx_coalesce_usecs = tx_itr_val;
7040 cp->rx_coalesce_usecs = rx_itr_val;
71
- return 0;
41
+ ret = 0;
42
+
43
+out:
44
+ mutex_unlock(&wil->mutex);
45
+ return ret;
7246 }
7347
7448 static int wil_ethtoolops_set_coalesce(struct net_device *ndev,
....@@ -78,12 +52,14 @@
7852 struct wireless_dev *wdev = ndev->ieee80211_ptr;
7953 int ret;
8054
55
+ mutex_lock(&wil->mutex);
8156 wil_dbg_misc(wil, "ethtoolops_set_coalesce: rx %d usec, tx %d usec\n",
8257 cp->rx_coalesce_usecs, cp->tx_coalesce_usecs);
8358
8459 if (wdev->iftype == NL80211_IFTYPE_MONITOR) {
8560 wil_dbg_misc(wil, "No IRQ coalescing in monitor mode\n");
86
- return -EINVAL;
61
+ ret = -EINVAL;
62
+ goto out;
8763 }
8864
8965 /* only @rx_coalesce_usecs and @tx_coalesce_usecs supported,
....@@ -99,24 +75,27 @@
9975
10076 ret = wil_pm_runtime_get(wil);
10177 if (ret < 0)
102
- return ret;
78
+ goto out;
10379
10480 wil->txrx_ops.configure_interrupt_moderation(wil);
10581
10682 wil_pm_runtime_put(wil);
83
+ ret = 0;
10784
108
- return 0;
85
+out:
86
+ mutex_unlock(&wil->mutex);
87
+ return ret;
10988
11089 out_bad:
11190 wil_dbg_misc(wil, "Unsupported coalescing params. Raw command:\n");
11291 print_hex_dump_debug("DBG[MISC] coal ", DUMP_PREFIX_OFFSET, 16, 4,
11392 cp, sizeof(*cp), false);
93
+ mutex_unlock(&wil->mutex);
11494 return -EINVAL;
11595 }
11696
11797 static const struct ethtool_ops wil_ethtool_ops = {
118
- .begin = wil_ethtoolops_begin,
119
- .complete = wil_ethtoolops_complete,
98
+ .supported_coalesce_params = ETHTOOL_COALESCE_USECS,
12099 .get_drvinfo = cfg80211_get_drvinfo,
121100 .get_coalesce = wil_ethtoolops_get_coalesce,
122101 .set_coalesce = wil_ethtoolops_set_coalesce,