Linux 3.18.86
[linux/fpc-iii.git] / drivers / net / wireless / ath / wil6210 / ethtool.c
blobd686638972bee238852dd1b7ae97715d6a533a2f
1 /*
2 * Copyright (c) 2014 Qualcomm Atheros, Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include <linux/etherdevice.h>
18 #include <linux/pci.h>
19 #include <linux/rtnetlink.h>
20 #include <net/cfg80211.h>
22 #include "wil6210.h"
24 static int wil_ethtoolops_begin(struct net_device *ndev)
26 struct wil6210_priv *wil = ndev_to_wil(ndev);
28 mutex_lock(&wil->mutex);
30 wil_dbg_misc(wil, "%s()\n", __func__);
32 return 0;
35 static void wil_ethtoolops_complete(struct net_device *ndev)
37 struct wil6210_priv *wil = ndev_to_wil(ndev);
39 wil_dbg_misc(wil, "%s()\n", __func__);
41 mutex_unlock(&wil->mutex);
44 static int wil_ethtoolops_get_coalesce(struct net_device *ndev,
45 struct ethtool_coalesce *cp)
47 struct wil6210_priv *wil = ndev_to_wil(ndev);
48 u32 itr_en, itr_val = 0;
50 wil_dbg_misc(wil, "%s()\n", __func__);
52 itr_en = ioread32(wil->csr + HOSTADDR(RGF_DMA_ITR_CNT_CRL));
53 if (itr_en & BIT_DMA_ITR_CNT_CRL_EN)
54 itr_val = ioread32(wil->csr + HOSTADDR(RGF_DMA_ITR_CNT_TRSH));
56 cp->rx_coalesce_usecs = itr_val;
58 return 0;
61 static int wil_ethtoolops_set_coalesce(struct net_device *ndev,
62 struct ethtool_coalesce *cp)
64 struct wil6210_priv *wil = ndev_to_wil(ndev);
66 wil_dbg_misc(wil, "%s(%d usec)\n", __func__, cp->rx_coalesce_usecs);
68 if (wil->wdev->iftype == NL80211_IFTYPE_MONITOR) {
69 wil_dbg_misc(wil, "No IRQ coalescing in monitor mode\n");
70 return -EINVAL;
73 /* only @rx_coalesce_usecs supported, ignore
74 * other parameters
77 if (cp->rx_coalesce_usecs > WIL6210_ITR_TRSH_MAX)
78 goto out_bad;
80 wil->itr_trsh = cp->rx_coalesce_usecs;
81 wil_set_itr_trsh(wil);
83 return 0;
85 out_bad:
86 wil_dbg_misc(wil, "Unsupported coalescing params. Raw command:\n");
87 print_hex_dump_debug("DBG[MISC] coal ", DUMP_PREFIX_OFFSET, 16, 4,
88 cp, sizeof(*cp), false);
89 return -EINVAL;
92 static const struct ethtool_ops wil_ethtool_ops = {
93 .begin = wil_ethtoolops_begin,
94 .complete = wil_ethtoolops_complete,
95 .get_drvinfo = cfg80211_get_drvinfo,
96 .get_coalesce = wil_ethtoolops_get_coalesce,
97 .set_coalesce = wil_ethtoolops_set_coalesce,
100 void wil_set_ethtoolops(struct net_device *ndev)
102 ndev->ethtool_ops = &wil_ethtool_ops;