| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: ISC |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2014,2017 Qualcomm Atheros, Inc. |
|---|
| 3 | 4 | * 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. |
|---|
| 16 | 5 | */ |
|---|
| 17 | 6 | |
|---|
| 18 | 7 | #include <linux/etherdevice.h> |
|---|
| .. | .. |
|---|
| 22 | 11 | |
|---|
| 23 | 12 | #include "wil6210.h" |
|---|
| 24 | 13 | |
|---|
| 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 | | - |
|---|
| 45 | 14 | static int wil_ethtoolops_get_coalesce(struct net_device *ndev, |
|---|
| 46 | 15 | struct ethtool_coalesce *cp) |
|---|
| 47 | 16 | { |
|---|
| .. | .. |
|---|
| 50 | 19 | u32 rx_itr_en, rx_itr_val = 0; |
|---|
| 51 | 20 | int ret; |
|---|
| 52 | 21 | |
|---|
| 22 | + mutex_lock(&wil->mutex); |
|---|
| 53 | 23 | wil_dbg_misc(wil, "ethtoolops_get_coalesce\n"); |
|---|
| 54 | 24 | |
|---|
| 55 | 25 | ret = wil_pm_runtime_get(wil); |
|---|
| 56 | 26 | if (ret < 0) |
|---|
| 57 | | - return ret; |
|---|
| 27 | + goto out; |
|---|
| 58 | 28 | |
|---|
| 59 | 29 | tx_itr_en = wil_r(wil, RGF_DMA_ITR_TX_CNT_CTL); |
|---|
| 60 | 30 | if (tx_itr_en & BIT_DMA_ITR_TX_CNT_CTL_EN) |
|---|
| .. | .. |
|---|
| 68 | 38 | |
|---|
| 69 | 39 | cp->tx_coalesce_usecs = tx_itr_val; |
|---|
| 70 | 40 | cp->rx_coalesce_usecs = rx_itr_val; |
|---|
| 71 | | - return 0; |
|---|
| 41 | + ret = 0; |
|---|
| 42 | + |
|---|
| 43 | +out: |
|---|
| 44 | + mutex_unlock(&wil->mutex); |
|---|
| 45 | + return ret; |
|---|
| 72 | 46 | } |
|---|
| 73 | 47 | |
|---|
| 74 | 48 | static int wil_ethtoolops_set_coalesce(struct net_device *ndev, |
|---|
| .. | .. |
|---|
| 78 | 52 | struct wireless_dev *wdev = ndev->ieee80211_ptr; |
|---|
| 79 | 53 | int ret; |
|---|
| 80 | 54 | |
|---|
| 55 | + mutex_lock(&wil->mutex); |
|---|
| 81 | 56 | wil_dbg_misc(wil, "ethtoolops_set_coalesce: rx %d usec, tx %d usec\n", |
|---|
| 82 | 57 | cp->rx_coalesce_usecs, cp->tx_coalesce_usecs); |
|---|
| 83 | 58 | |
|---|
| 84 | 59 | if (wdev->iftype == NL80211_IFTYPE_MONITOR) { |
|---|
| 85 | 60 | wil_dbg_misc(wil, "No IRQ coalescing in monitor mode\n"); |
|---|
| 86 | | - return -EINVAL; |
|---|
| 61 | + ret = -EINVAL; |
|---|
| 62 | + goto out; |
|---|
| 87 | 63 | } |
|---|
| 88 | 64 | |
|---|
| 89 | 65 | /* only @rx_coalesce_usecs and @tx_coalesce_usecs supported, |
|---|
| .. | .. |
|---|
| 99 | 75 | |
|---|
| 100 | 76 | ret = wil_pm_runtime_get(wil); |
|---|
| 101 | 77 | if (ret < 0) |
|---|
| 102 | | - return ret; |
|---|
| 78 | + goto out; |
|---|
| 103 | 79 | |
|---|
| 104 | 80 | wil->txrx_ops.configure_interrupt_moderation(wil); |
|---|
| 105 | 81 | |
|---|
| 106 | 82 | wil_pm_runtime_put(wil); |
|---|
| 83 | + ret = 0; |
|---|
| 107 | 84 | |
|---|
| 108 | | - return 0; |
|---|
| 85 | +out: |
|---|
| 86 | + mutex_unlock(&wil->mutex); |
|---|
| 87 | + return ret; |
|---|
| 109 | 88 | |
|---|
| 110 | 89 | out_bad: |
|---|
| 111 | 90 | wil_dbg_misc(wil, "Unsupported coalescing params. Raw command:\n"); |
|---|
| 112 | 91 | print_hex_dump_debug("DBG[MISC] coal ", DUMP_PREFIX_OFFSET, 16, 4, |
|---|
| 113 | 92 | cp, sizeof(*cp), false); |
|---|
| 93 | + mutex_unlock(&wil->mutex); |
|---|
| 114 | 94 | return -EINVAL; |
|---|
| 115 | 95 | } |
|---|
| 116 | 96 | |
|---|
| 117 | 97 | 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, |
|---|
| 120 | 99 | .get_drvinfo = cfg80211_get_drvinfo, |
|---|
| 121 | 100 | .get_coalesce = wil_ethtoolops_get_coalesce, |
|---|
| 122 | 101 | .set_coalesce = wil_ethtoolops_set_coalesce, |
|---|