* Re: [PATCH RFC 2/2] brcmfmac: add brcmf_err_pub macro for better error messages
From: Arend Van Spriel @ 2017-01-20 10:26 UTC (permalink / raw)
To: Rafał Miłecki, Kalle Valo
Cc: Franky Lin, Hante Meuleman, Pieter-Paul Giesberts, Franky Lin,
linux-wireless, brcm80211-dev-list.pdl, Rafał Miłecki
In-Reply-To: <20170118142703.9824-2-zajec5@gmail.com>
On 18-1-2017 15:27, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
>
> This macro accepts an extra argument of struct brcmf_pub pointer. It
> allows referencing struct device and printing error using dev_err. This
> is very useful on devices with more than one wireless card suppored by
> brcmfmac. Thanks for dev_err it's possible to identify device that error
> is related to.
>
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> ---
> I could convert few more brcmf_err calls to this new brcmf_err_pub but I don't
> want to spent too much time on this in case someone has a better idea.
>
> If you do, comment! :)
I do not, but still comment ;-). Like the idea. Was on our list because
it is damn convenient when testing on router with multiple devices. I
would prefer to replace the existing brcmf_err() rather than introducing
a new one and would like to do the same for brcmf_dbg(). However, not
all call sites have a struct brcmf_pub instance available. Everywhere
before completing brcmf_attach() that is.
Regards,
Arend
> Example
> Before:
> [ 14.735640] brcmfmac: brcmf_c_preinit_dcmds: Firmware version = wl0: Sep 18 2015 03:30:01 version 7.35.177.56 (r587209) FWID 01-6cb8e269
> [ 15.155732] brcmfmac: brcmf_c_preinit_dcmds: Firmware version = wl0: Sep 18 2015 03:30:01 version 7.35.177.56 (r587209) FWID 01-6cb8e269
> [ 15.535682] brcmfmac: brcmf_c_preinit_dcmds: Firmware version = wl0: Sep 18 2015 03:30:01 version 7.35.177.56 (r587209) FWID 01-6cb8e269
> After:
> [ 14.746754] brcmfmac 0000:01:00.0: brcmf_c_preinit_dcmds: Firmware version = wl0: Sep 18 2015 03:30:01 version 7.35.177.56 (r587209) FWID 01-6cb8e269
> [ 15.166854] brcmfmac 0001:03:00.0: brcmf_c_preinit_dcmds: Firmware version = wl0: Sep 18 2015 03:30:01 version 7.35.177.56 (r587209) FWID 01-6cb8e269
> [ 15.546807] brcmfmac 0001:04:00.0: brcmf_c_preinit_dcmds: Firmware version = wl0: Sep 18 2015 03:30:01 version 7.35.177.56 (r587209) FWID 01-6cb8e269
> ---
> .../wireless/broadcom/brcm80211/brcmfmac/common.c | 19 ++++++-------
> .../wireless/broadcom/brcm80211/brcmfmac/core.c | 31 +++++++++++-----------
> .../wireless/broadcom/brcm80211/brcmfmac/debug.h | 17 ++++++++----
> .../broadcom/brcm80211/brcmfmac/tracepoint.c | 4 +--
> 4 files changed, 40 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
> index 5fb4a14..7a05de78 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
> @@ -108,6 +108,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
> {
> s8 eventmask[BRCMF_EVENTING_MASK_LEN];
> u8 buf[BRCMF_DCMD_SMLEN];
> + struct brcmf_pub *pub = ifp->drvr;
> struct brcmf_rev_info_le revinfo;
> struct brcmf_rev_info *ri;
> char *ptr;
> @@ -117,7 +118,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
> err = brcmf_fil_iovar_data_get(ifp, "cur_etheraddr", ifp->mac_addr,
> sizeof(ifp->mac_addr));
> if (err < 0) {
> - brcmf_err("Retreiving cur_etheraddr failed, %d\n", err);
> + brcmf_err_pub(pub, "Retreiving cur_etheraddr failed, %d\n", err);
> goto done;
> }
> memcpy(ifp->drvr->mac, ifp->mac_addr, sizeof(ifp->drvr->mac));
> @@ -126,7 +127,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
> &revinfo, sizeof(revinfo));
> ri = &ifp->drvr->revinfo;
> if (err < 0) {
> - brcmf_err("retrieving revision info failed, %d\n", err);
> + brcmf_err_pub(pub, "retrieving revision info failed, %d\n", err);
> } else {
> ri->vendorid = le32_to_cpu(revinfo.vendorid);
> ri->deviceid = le32_to_cpu(revinfo.deviceid);
> @@ -153,7 +154,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
> strcpy(buf, "ver");
> err = brcmf_fil_iovar_data_get(ifp, "ver", buf, sizeof(buf));
> if (err < 0) {
> - brcmf_err("Retreiving version information failed, %d\n",
> + brcmf_err_pub(pub, "Retreiving version information failed, %d\n",
> err);
> goto done;
> }
> @@ -161,7 +162,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
> strsep(&ptr, "\n");
>
> /* Print fw version info */
> - brcmf_err("Firmware version = %s\n", buf);
> + brcmf_err_pub(pub, "Firmware version = %s\n", buf);
>
> /* locate firmware version number for ethtool */
> ptr = strrchr(buf, ' ') + 1;
> @@ -170,7 +171,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
> /* set mpc */
> err = brcmf_fil_iovar_int_set(ifp, "mpc", 1);
> if (err) {
> - brcmf_err("failed setting mpc\n");
> + brcmf_err_pub(pub, "failed setting mpc\n");
> goto done;
> }
>
> @@ -180,14 +181,14 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
> err = brcmf_fil_iovar_data_get(ifp, "event_msgs", eventmask,
> BRCMF_EVENTING_MASK_LEN);
> if (err) {
> - brcmf_err("Get event_msgs error (%d)\n", err);
> + brcmf_err_pub(pub, "Get event_msgs error (%d)\n", err);
> goto done;
> }
> setbit(eventmask, BRCMF_E_IF);
> err = brcmf_fil_iovar_data_set(ifp, "event_msgs", eventmask,
> BRCMF_EVENTING_MASK_LEN);
> if (err) {
> - brcmf_err("Set event_msgs error (%d)\n", err);
> + brcmf_err_pub(pub, "Set event_msgs error (%d)\n", err);
> goto done;
> }
>
> @@ -195,7 +196,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
> err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_CHANNEL_TIME,
> BRCMF_DEFAULT_SCAN_CHANNEL_TIME);
> if (err) {
> - brcmf_err("BRCMF_C_SET_SCAN_CHANNEL_TIME error (%d)\n",
> + brcmf_err_pub(pub, "BRCMF_C_SET_SCAN_CHANNEL_TIME error (%d)\n",
> err);
> goto done;
> }
> @@ -204,7 +205,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
> err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_UNASSOC_TIME,
> BRCMF_DEFAULT_SCAN_UNASSOC_TIME);
> if (err) {
> - brcmf_err("BRCMF_C_SET_SCAN_UNASSOC_TIME error (%d)\n",
> + brcmf_err_pub(pub, "BRCMF_C_SET_SCAN_UNASSOC_TIME error (%d)\n",
> err);
> goto done;
> }
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
> index b73a55b..a42007b 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
> @@ -59,7 +59,7 @@ struct brcmf_if *brcmf_get_ifp(struct brcmf_pub *drvr, int ifidx)
> s32 bsscfgidx;
>
> if (ifidx < 0 || ifidx >= BRCMF_MAX_IFS) {
> - brcmf_err("ifidx %d out of range\n", ifidx);
> + brcmf_err_pub(drvr, "ifidx %d out of range\n", ifidx);
> return NULL;
> }
>
> @@ -204,7 +204,8 @@ static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff *skb,
>
> /* Can the device send data? */
> if (drvr->bus_if->state != BRCMF_BUS_UP) {
> - brcmf_err("xmit rejected state=%d\n", drvr->bus_if->state);
> + brcmf_err_pub(drvr, "xmit rejected state=%d\n",
> + drvr->bus_if->state);
> netif_stop_queue(ndev);
> dev_kfree_skb(skb);
> ret = -ENODEV;
> @@ -222,7 +223,7 @@ static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff *skb,
> dev_kfree_skb(skb);
> skb = skb2;
> if (skb == NULL) {
> - brcmf_err("%s: skb_realloc_headroom failed\n",
> + brcmf_err_pub(drvr, "%s: skb_realloc_headroom failed\n",
> brcmf_ifname(ifp));
> ret = -ENOMEM;
> goto done;
> @@ -466,7 +467,7 @@ static int brcmf_netdev_open(struct net_device *ndev)
>
> /* If bus is not ready, can't continue */
> if (bus_if->state != BRCMF_BUS_UP) {
> - brcmf_err("failed bus is not ready\n");
> + brcmf_err_pub(drvr, "failed bus is not ready\n");
> return -EAGAIN;
> }
>
> @@ -480,7 +481,7 @@ static int brcmf_netdev_open(struct net_device *ndev)
> ndev->features &= ~NETIF_F_IP_CSUM;
>
> if (brcmf_cfg80211_up(ndev)) {
> - brcmf_err("failed to bring up cfg80211\n");
> + brcmf_err_pub(drvr, "failed to bring up cfg80211\n");
> return -EIO;
> }
>
> @@ -525,7 +526,7 @@ int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked)
> else
> err = register_netdev(ndev);
> if (err != 0) {
> - brcmf_err("couldn't register the net device\n");
> + brcmf_err_pub(drvr, "couldn't register the net device\n");
> goto fail;
> }
>
> @@ -643,7 +644,7 @@ struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bsscfgidx, s32 ifidx,
> */
> if (ifp) {
> if (ifidx) {
> - brcmf_err("ERROR: netdev:%s already exists\n",
> + brcmf_err_pub(drvr, "ERROR: netdev:%s already exists\n",
> ifp->ndev->name);
> netif_stop_queue(ifp->ndev);
> brcmf_net_detach(ifp->ndev, false);
> @@ -702,7 +703,7 @@ static void brcmf_del_if(struct brcmf_pub *drvr, s32 bsscfgidx,
> ifp = drvr->iflist[bsscfgidx];
> drvr->iflist[bsscfgidx] = NULL;
> if (!ifp) {
> - brcmf_err("Null interface, bsscfgidx=%d\n", bsscfgidx);
> + brcmf_err_pub(drvr, "Null interface, bsscfgidx=%d\n", bsscfgidx);
> return;
> }
> brcmf_dbg(TRACE, "Enter, bsscfgidx=%d, ifidx=%d\n", bsscfgidx,
> @@ -787,7 +788,7 @@ static int brcmf_inetaddr_changed(struct notifier_block *nb,
> ret = brcmf_fil_iovar_data_get(ifp, "arp_hostip", addr_table,
> sizeof(addr_table));
> if (ret) {
> - brcmf_err("fail to get arp ip table err:%d\n", ret);
> + brcmf_err_pub(drvr, "fail to get arp ip table err:%d\n", ret);
> return NOTIFY_OK;
> }
>
> @@ -804,7 +805,7 @@ static int brcmf_inetaddr_changed(struct notifier_block *nb,
> ret = brcmf_fil_iovar_data_set(ifp, "arp_hostip",
> &ifa->ifa_address, sizeof(ifa->ifa_address));
> if (ret)
> - brcmf_err("add arp ip err %d\n", ret);
> + brcmf_err_pub(drvr, "add arp ip err %d\n", ret);
> }
> break;
> case NETDEV_DOWN:
> @@ -816,7 +817,7 @@ static int brcmf_inetaddr_changed(struct notifier_block *nb,
> ret = brcmf_fil_iovar_data_set(ifp, "arp_hostip_clear",
> NULL, 0);
> if (ret) {
> - brcmf_err("fail to clear arp ip table err:%d\n",
> + brcmf_err_pub(drvr, "fail to clear arp ip table err:%d\n",
> ret);
> return NOTIFY_OK;
> }
> @@ -827,7 +828,7 @@ static int brcmf_inetaddr_changed(struct notifier_block *nb,
> &addr_table[i],
> sizeof(addr_table[i]));
> if (ret)
> - brcmf_err("add arp ip err %d\n",
> + brcmf_err_pub(drvr, "add arp ip err %d\n",
> ret);
> }
> }
> @@ -923,7 +924,7 @@ int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings)
> /* Attach and link in the protocol */
> ret = brcmf_proto_attach(drvr);
> if (ret != 0) {
> - brcmf_err("brcmf_prot_attach failed\n");
> + brcmf_err_pub(drvr, "brcmf_prot_attach failed\n");
> goto fail;
> }
>
> @@ -1045,7 +1046,7 @@ int brcmf_bus_started(struct device *dev)
> return 0;
>
> fail:
> - brcmf_err("failed: %d\n", ret);
> + brcmf_err_pub(drvr, "failed: %d\n", ret);
> if (drvr->config) {
> brcmf_cfg80211_detach(drvr->config);
> drvr->config = NULL;
> @@ -1152,7 +1153,7 @@ int brcmf_netdev_wait_pend8021x(struct brcmf_if *ifp)
> MAX_WAIT_FOR_8021X_TX);
>
> if (!err)
> - brcmf_err("Timed out waiting for no pending 802.1x packets\n");
> + brcmf_err_pub(ifp->drvr, "Timed out waiting for no pending 802.1x packets\n");
>
> return !err;
> }
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
> index 1fe4aa9..aab8c71 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
> @@ -50,16 +50,23 @@
> * debugging is not selected. When debugging the driver error
> * messages are as important as other tracing or even more so.
> */
> -#define brcmf_err(fmt, ...) \
> +#define __brcmf_err(dev, fmt, ...) \
> do { \
> if (IS_ENABLED(CONFIG_BRCMDBG) || net_ratelimit()) \
> - pr_err("%s: " fmt, __func__, ##__VA_ARGS__); \
> + dev_err(dev, "%s: " fmt, __func__, \
> + ##__VA_ARGS__); \
> } while (0)
> +#define brcmf_err(fmt, ...) \
> + __brcmf_err(NULL, fmt, ##__VA_ARGS__)
> +#define brcmf_err_pub(pub, fmt, ...) \
> + __brcmf_err(pub->bus_if->dev, fmt, ##__VA_ARGS__)
> #else
> -__printf(2, 3)
> -void __brcmf_err(const char *func, const char *fmt, ...);
> +__printf(3, 4)
> +void __brcmf_err(struct brcmf_pub *pub, const char *func, const char *fmt, ...);
> #define brcmf_err(fmt, ...) \
> - __brcmf_err(__func__, fmt, ##__VA_ARGS__)
> + __brcmf_err(NULL, __func__, fmt, ##__VA_ARGS__)
> +#define brcmf_err_pub(fmt, ...) \
> + __brcmf_err(pub, __func__, fmt, ##__VA_ARGS__)
> #endif
>
> #if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c
> index fe67559..3e8d60b 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c
> @@ -21,7 +21,7 @@
> #include "tracepoint.h"
> #include "debug.h"
>
> -void __brcmf_err(const char *func, const char *fmt, ...)
> +void __brcmf_err(struct brcmf_pub *pub, const char *func, const char *fmt, ...)
> {
> struct va_format vaf = {
> .fmt = fmt,
> @@ -30,7 +30,7 @@ void __brcmf_err(const char *func, const char *fmt, ...)
>
> va_start(args, fmt);
> vaf.va = &args;
> - pr_err("%s: %pV", func, &vaf);
> + dev_err(pub ? pub->bus_if->dev, NULL, "%s: %pV", func, &vaf);
> trace_brcmf_err(func, &vaf);
> va_end(args);
> }
>
^ permalink raw reply
* Re: [PATCH RFC 1/2] brcmfmac: merge two brcmf_err macros into one
From: Rafał Miłecki @ 2017-01-20 10:58 UTC (permalink / raw)
To: Arend Van Spriel
Cc: Kalle Valo, Franky Lin, Hante Meuleman, Pieter-Paul Giesberts,
Franky Lin, linux-wireless@vger.kernel.org,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
Rafał Miłecki
In-Reply-To: <52453214-bab2-dc0b-c684-2389fe028442@broadcom.com>
On 20 January 2017 at 11:14, Arend Van Spriel
<arend.vanspriel@broadcom.com> wrote:
> On 20-1-2017 11:13, Arend Van Spriel wrote:
>> On 18-1-2017 15:27, Rafa=C5=82 Mi=C5=82ecki wrote:
>>> From: Rafa=C5=82 Mi=C5=82ecki <rafal@milecki.pl>
>>>
>>> This allows simplifying the code by adding a simple IS_ENABLED check fo=
r
>>> CONFIG_BRCMDB symbol.
>
> Actually it should be CONFIG_BRCMDBG above.
>
> Kalle,
>
> Can you fix that in the commit message?
It's only RFC, I'll make sure to fix that in final version
--=20
Rafa=C5=82
^ permalink raw reply
* Re: [PATCH RFC 1/2] brcmfmac: merge two brcmf_err macros into one
From: Arend Van Spriel @ 2017-01-20 11:03 UTC (permalink / raw)
To: Rafał Miłecki
Cc: Kalle Valo, Franky Lin, Hante Meuleman, Pieter-Paul Giesberts,
Franky Lin, linux-wireless@vger.kernel.org,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
Rafał Miłecki
In-Reply-To: <CACna6rwhe+Vupq=7CxQAQfRce2_gH7kNj1QwRyoCpTLms+mn5Q@mail.gmail.com>
On 20-1-2017 11:58, Rafał Miłecki wrote:
> On 20 January 2017 at 11:14, Arend Van Spriel
> <arend.vanspriel@broadcom.com> wrote:
>> On 20-1-2017 11:13, Arend Van Spriel wrote:
>>> On 18-1-2017 15:27, Rafał Miłecki wrote:
>>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>>
>>>> This allows simplifying the code by adding a simple IS_ENABLED check for
>>>> CONFIG_BRCMDB symbol.
>>
>> Actually it should be CONFIG_BRCMDBG above.
>>
>> Kalle,
>>
>> Can you fix that in the commit message?
>
> It's only RFC, I'll make sure to fix that in final version
You're right. Missed that.
Regards,
Arend
^ permalink raw reply
* Re: Re: [PATCH] rtlwifi: rtl8192x: Enabling and disabling hardware interrupts after enabling local irq flags
From: Lino Sanfilippo @ 2017-01-20 11:14 UTC (permalink / raw)
To: Larry Finger
Cc: Bharat Kumar Gogada, chaoming_li, linux-wireless, linux-kernel,
kvalo, netdev, rgummal, Bharat Kumar Gogada
In-Reply-To: <b2e783f6-fa09-e287-8119-266299cdae22@lwfinger.net>
Hi,
>
>
> This patch should be enhanced with the smb_xx() calls as suggested by by Lino.
>
If you do this, please place the smp_rmb() before the if condition in the irq
handler like
smp_rmb();
if (rtlpci->irq_enabled == 0) {
return ret;
as I think that the suggestion I made before was not correct (sorry for the
confusion).
Regards,
Lino
^ permalink raw reply
* Re: [PATCH RFC 2/2] brcmfmac: add brcmf_err_pub macro for better error messages
From: Rafał Miłecki @ 2017-01-20 11:17 UTC (permalink / raw)
To: Arend Van Spriel, Kalle Valo
Cc: Franky Lin, Hante Meuleman, Pieter-Paul Giesberts, Franky Lin,
linux-wireless, brcm80211-dev-list.pdl, Rafał Miłecki
In-Reply-To: <8819000f-f70f-e8b3-ca52-eebf10a431ac@broadcom.com>
On 01/20/2017 11:26 AM, Arend Van Spriel wrote:
> On 18-1-2017 15:27, Rafał Miłecki wrote:
>> From: Rafał Miłecki <rafal@milecki.pl>
>>
>> This macro accepts an extra argument of struct brcmf_pub pointer. It
>> allows referencing struct device and printing error using dev_err. This
>> is very useful on devices with more than one wireless card suppored by
>> brcmfmac. Thanks for dev_err it's possible to identify device that error
>> is related to.
>>
>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>> ---
>> I could convert few more brcmf_err calls to this new brcmf_err_pub but I don't
>> want to spent too much time on this in case someone has a better idea.
>>
>> If you do, comment! :)
>
> I do not, but still comment ;-). Like the idea. Was on our list because
> it is damn convenient when testing on router with multiple devices. I
> would prefer to replace the existing brcmf_err() rather than introducing
> a new one and would like to do the same for brcmf_dbg(). However, not
> all call sites have a struct brcmf_pub instance available. Everywhere
> before completing brcmf_attach() that is.
I decided to try new macro because:
1) I was too lazy to convert all calls at once
2) I could stick to brcmf_err when struct brcmf_pub isn't available yet
In theory we could pass NULL to dev_err, I'd result in something like:
[ 14.746754] (NULL device *): brcmf_c_preinit_dcmds: Firmware version = wl0: Sep 18 2015 03:30:01 version 7.35.177.56 (r587209) FWID 01-6cb8e269
Unfortunately AFAIK it's not possible to handle
brcmf_err(NULL "Foo\n");
calls while keeping brcmf_err a macro.
I was thinking about something like:
#define brcmf_err(pub, fmt, ...) \
do { \
if (IS_ENABLED(CONFIG_BRCMDBG) || net_ratelimit()) \
dev_err(pub ? pub->bus_if->dev : NULL, \
"%s: " fmt, __func__, \
##__VA_ARGS__); \
} while (0)
but this wouldn't compile because for brcmf_err(NULL "Foo\n"); it would roll
out to:
dev_err(NULL ? NULL->bus_if->dev : NULL, "Foo\n");
I *can* support brcmf_err(NULL "Foo\n"); calls if I change brcmf_err from
macro to a function (inline probably). Do you think it's a good idea?
^ permalink raw reply
* Re: [PATCH RFC 2/2] brcmfmac: add brcmf_err_pub macro for better error messages
From: Arend Van Spriel @ 2017-01-20 11:37 UTC (permalink / raw)
To: Rafał Miłecki, Kalle Valo
Cc: Franky Lin, Hante Meuleman, Pieter-Paul Giesberts, Franky Lin,
linux-wireless, brcm80211-dev-list.pdl, Rafał Miłecki
In-Reply-To: <e67a5583-8a1b-b370-5dcb-8717197542fb@gmail.com>
On 20-1-2017 12:17, Rafał Miłecki wrote:
> On 01/20/2017 11:26 AM, Arend Van Spriel wrote:
>> On 18-1-2017 15:27, Rafał Miłecki wrote:
>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>
>>> This macro accepts an extra argument of struct brcmf_pub pointer. It
>>> allows referencing struct device and printing error using dev_err. This
>>> is very useful on devices with more than one wireless card suppored by
>>> brcmfmac. Thanks for dev_err it's possible to identify device that error
>>> is related to.
>>>
>>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>>> ---
>>> I could convert few more brcmf_err calls to this new brcmf_err_pub
>>> but I don't
>>> want to spent too much time on this in case someone has a better idea.
>>>
>>> If you do, comment! :)
>>
>> I do not, but still comment ;-). Like the idea. Was on our list because
>> it is damn convenient when testing on router with multiple devices. I
>> would prefer to replace the existing brcmf_err() rather than introducing
>> a new one and would like to do the same for brcmf_dbg(). However, not
>> all call sites have a struct brcmf_pub instance available. Everywhere
>> before completing brcmf_attach() that is.
>
> I decided to try new macro because:
> 1) I was too lazy to convert all calls at once
> 2) I could stick to brcmf_err when struct brcmf_pub isn't available yet
>
> In theory we could pass NULL to dev_err, I'd result in something like:
> [ 14.746754] (NULL device *): brcmf_c_preinit_dcmds: Firmware version
> = wl0: Sep 18 2015 03:30:01 version 7.35.177.56 (r587209) FWID 01-6cb8e269
>
> Unfortunately AFAIK it's not possible to handle
> brcmf_err(NULL "Foo\n");
> calls while keeping brcmf_err a macro.
>
> I was thinking about something like:
> #define brcmf_err(pub, fmt, ...) \
> do { \
> if (IS_ENABLED(CONFIG_BRCMDBG) || net_ratelimit()) \
> dev_err(pub ? pub->bus_if->dev : NULL, \
> "%s: " fmt, __func__, \
> ##__VA_ARGS__); \
> } while (0)
>
> but this wouldn't compile because for brcmf_err(NULL "Foo\n"); it would
> roll
> out to:
> dev_err(NULL ? NULL->bus_if->dev : NULL, "Foo\n");
>
> I *can* support brcmf_err(NULL "Foo\n"); calls if I change brcmf_err from
> macro to a function (inline probably). Do you think it's a good idea?
I was wondering if brcmf_err(ptr, "bla\n") could determine the pointer
type and accept 'struct device *' and 'struct brcmf_pub *'. I think we
always have a struct device pointer. Only in brcmf_module_init() we do not.
Regards,
Arend
^ permalink raw reply
* Re: [PATCH] net: ethtool: avoid allocation failure for dump_regs
From: Kalle Valo @ 2017-01-20 11:44 UTC (permalink / raw)
To: David Miller; +Cc: linville, darcari, netdev, johannes.berg, linux-wireless
In-Reply-To: <20170119.142230.1012416564568457058.davem@davemloft.net>
David Miller <davem@davemloft.net> writes:
> From: Kalle Valo <kvalo@codeaurora.org>
> Date: Thu, 19 Jan 2017 20:08:30 +0200
>
>> "John W. Linville" <linville@tuxdriver.com> writes:
>>
>>> I forgot to Cc Johannes and Kalle...
>>
>> Also adding linux-wireless.
>>
>>> On Thu, Jan 19, 2017 at 09:15:09AM -0500, John W. Linville wrote:
>>>
>>>> I'm responsible for this mess. The original idea was for various
>>>> mac80211-based drivers to override the ethtool operation and provide
>>>> their own dump operation, but the mac80211 crowd never embraced
>>>> the idea.
>>>>
>>>> In the meantime, I added the default implementation which just
>>>> passed-up wdev->wiphy->hw_version as the version info for a 0-length
>>>> register dump. I then implemented a driver-specific regiser dump
>>>> handler for userland ethtool that would interpret the hardware version
>>>> information for the at76c50x-usb driver.
>>>>
>>>> So the net of it is, if we treat a return of 0 from get_regs_len()
>>>> as "not supported", we break this one driver-specific feature for
>>>> userland ethtool. Realistically, there are probably very few users
>>>> to care. But I can't guarantee that the number is zero.
>>
>> I know the number is not zero, because I remember using it years back
>> with something else than at76c50x-usb. But is the number more than one,
>> I don't know :)
>
> I'm trying to dig down and figure out why this problem is showing up now.
> ethtool_get_regs() has been using vzalloc() since 2011, and before that it
> used plain vmalloc().
>
> This code has therefore been using v{m,z}alloc() forever. What changed?
>
> The zero size check has been in the vmalloc implementation since at least
> 2009.
>
> I don't understand why this is all triggering and being noticed now. The
> whole ieee80211 "return zero length regs and return hw version in get_regs"
> thing should have been failing for at least 7 years now.
Maybe just nobody hasn't used it since? If my memory serves me right
(too often it does not) It's 6-7 years since I used this, and if the
kernel I worked on at the time was a year or two old, I might have used
a version without the zero size check.
But I'm just hand-waving here, I cannot be sure what's the last kernel I
used.
--
Kalle Valo
^ permalink raw reply
* Re: [RFC] ath10k: silence firmware file probing warnings
From: Kalle Valo @ 2017-01-20 12:51 UTC (permalink / raw)
To: Michal Kazior; +Cc: linux-wireless, ath10k
In-Reply-To: <1468933237-5226-1-git-send-email-michal.kazior@tieto.com>
Michal Kazior <michal.kazior@tieto.com> wrote:
> Firmware files are versioned to prevent older
> driver instances to load unsupported firmware
> blobs. This is reflected with a fallback logic
> which attempts to load several firmware files.
>
> This however produced a lot of unnecessary
> warnings sometimes confusing users and leading
> them to rename firmware files making things even
> more confusing.
>
> Hence use request_firmware_direct() which does not
> produce extra warnings. This shouldn't really
> break anything because most modern systems don't
> rely on udev/hotplug helpers to load firmware
> files anymore.
>
> Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
This ended into a rather long discussion, see the full thread from the patchwork link
below, but I'll try to summarise it here:
* Nobody stepped up and mentioned that they need/use the user fallback helper with ath10k.
* Felix confirmed that LEDE creates the calibration file before loading ath10k
so this should not break LEDE.
* This also fixes a 60 second delay per _each_ unexistent firmware/calibration
file with distros which have CONFIG_FW_LOADER_USER_HELPER_FALLBACK enabled,
RHEL being a notable example. Using ath10k with firmware-2.bin this might
end up into a five minute delay in boot.
* Luis is working on new drvdata interface for kernel, but that's not merged yet.
Based on this I think the right approach is to apply this patch. Any concerns?
While writing this I started to suspect is it just by accident that
request_firmware_direct() does not print any error messages and
request_firmware() again does print those? Let's hope nobody decides to change
that. And at least Luis' drvdata interface has a documented 'optional' flag,
so we can always switch to using that (once it's merged):
* struct drvdata_req_params - driver data request parameters
* @optional: if true it is not a hard requirement by the caller that this
* file be present. An error will not be recorded if the file is not
* found.
Michal, do you mind if I'll add more info to the commit log and submit this RFC
as a proper patch? It still seems to apply and work just fine.
--
https://patchwork.kernel.org/patch/9237095/
Documentation about submitting wireless patches and checking status
from patchwork:
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply
* Re: [PATCH RFC 2/2] brcmfmac: add brcmf_err_pub macro for better error messages
From: Rafał Miłecki @ 2017-01-20 12:52 UTC (permalink / raw)
To: Arend Van Spriel
Cc: Kalle Valo, Franky Lin, Hante Meuleman, Pieter-Paul Giesberts,
Franky Lin, linux-wireless@vger.kernel.org,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
Rafał Miłecki
In-Reply-To: <668216db-8834-02e6-1b7c-9fbd05eeaf68@broadcom.com>
On 20 January 2017 at 12:37, Arend Van Spriel
<arend.vanspriel@broadcom.com> wrote:
> On 20-1-2017 12:17, Rafa=C5=82 Mi=C5=82ecki wrote:
>> On 01/20/2017 11:26 AM, Arend Van Spriel wrote:
>>> On 18-1-2017 15:27, Rafa=C5=82 Mi=C5=82ecki wrote:
>>>> From: Rafa=C5=82 Mi=C5=82ecki <rafal@milecki.pl>
>>>>
>>>> This macro accepts an extra argument of struct brcmf_pub pointer. It
>>>> allows referencing struct device and printing error using dev_err. Thi=
s
>>>> is very useful on devices with more than one wireless card suppored by
>>>> brcmfmac. Thanks for dev_err it's possible to identify device that err=
or
>>>> is related to.
>>>>
>>>> Signed-off-by: Rafa=C5=82 Mi=C5=82ecki <rafal@milecki.pl>
>>>> ---
>>>> I could convert few more brcmf_err calls to this new brcmf_err_pub
>>>> but I don't
>>>> want to spent too much time on this in case someone has a better idea.
>>>>
>>>> If you do, comment! :)
>>>
>>> I do not, but still comment ;-). Like the idea. Was on our list because
>>> it is damn convenient when testing on router with multiple devices. I
>>> would prefer to replace the existing brcmf_err() rather than introducin=
g
>>> a new one and would like to do the same for brcmf_dbg(). However, not
>>> all call sites have a struct brcmf_pub instance available. Everywhere
>>> before completing brcmf_attach() that is.
>>
>> I decided to try new macro because:
>> 1) I was too lazy to convert all calls at once
>> 2) I could stick to brcmf_err when struct brcmf_pub isn't available yet
>>
>> In theory we could pass NULL to dev_err, I'd result in something like:
>> [ 14.746754] (NULL device *): brcmf_c_preinit_dcmds: Firmware version
>> =3D wl0: Sep 18 2015 03:30:01 version 7.35.177.56 (r587209) FWID 01-6cb8=
e269
>>
>> Unfortunately AFAIK it's not possible to handle
>> brcmf_err(NULL "Foo\n");
>> calls while keeping brcmf_err a macro.
>>
>> I was thinking about something like:
>> #define brcmf_err(pub, fmt, ...) \
>> do { \
>> if (IS_ENABLED(CONFIG_BRCMDBG) || net_ratelimit()) \
>> dev_err(pub ? pub->bus_if->dev : NULL, \
>> "%s: " fmt, __func__, \
>> ##__VA_ARGS__); \
>> } while (0)
>>
>> but this wouldn't compile because for brcmf_err(NULL "Foo\n"); it would
>> roll
>> out to:
>> dev_err(NULL ? NULL->bus_if->dev : NULL, "Foo\n");
>>
>> I *can* support brcmf_err(NULL "Foo\n"); calls if I change brcmf_err fro=
m
>> macro to a function (inline probably). Do you think it's a good idea?
>
> I was wondering if brcmf_err(ptr, "bla\n") could determine the pointer
> type and accept 'struct device *' and 'struct brcmf_pub *'. I think we
> always have a struct device pointer. Only in brcmf_module_init() we do no=
t.
Is this possible with a macro? Could you point me to some example for
something like this?
Also is this acceptable for upstream code?
--=20
Rafa=C5=82
^ permalink raw reply
* Re: [RFC] ath10k: silence firmware file probing warnings
From: Michal Kazior @ 2017-01-20 12:56 UTC (permalink / raw)
To: Kalle Valo; +Cc: linux-wireless, ath10k@lists.infradead.org
In-Reply-To: <6e5d0596c4af46668c02356ba17a4e5f@euamsexm01a.eu.qualcomm.com>
On 20 January 2017 at 13:51, Kalle Valo <kvalo@qca.qualcomm.com> wrote:
> Michal Kazior <michal.kazior@tieto.com> wrote:
>> Firmware files are versioned to prevent older
>> driver instances to load unsupported firmware
>> blobs. This is reflected with a fallback logic
>> which attempts to load several firmware files.
>>
>> This however produced a lot of unnecessary
>> warnings sometimes confusing users and leading
>> them to rename firmware files making things even
>> more confusing.
>>
>> Hence use request_firmware_direct() which does not
>> produce extra warnings. This shouldn't really
>> break anything because most modern systems don't
>> rely on udev/hotplug helpers to load firmware
>> files anymore.
>>
>> Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
>
> This ended into a rather long discussion, see the full thread from the pa=
tchwork link
> below, but I'll try to summarise it here:
>
> * Nobody stepped up and mentioned that they need/use the user fallback he=
lper with ath10k.
>
> * Felix confirmed that LEDE creates the calibration file before loading a=
th10k
> so this should not break LEDE.
>
> * This also fixes a 60 second delay per _each_ unexistent firmware/calibr=
ation
> file with distros which have CONFIG_FW_LOADER_USER_HELPER_FALLBACK enab=
led,
> RHEL being a notable example. Using ath10k with firmware-2.bin this mig=
ht
> end up into a five minute delay in boot.
>
> * Luis is working on new drvdata interface for kernel, but that's not mer=
ged yet.
>
> Based on this I think the right approach is to apply this patch. Any conc=
erns?
>
> While writing this I started to suspect is it just by accident that
> request_firmware_direct() does not print any error messages and
> request_firmware() again does print those? Let's hope nobody decides to c=
hange
> that. And at least Luis' drvdata interface has a documented 'optional' f=
lag,
> so we can always switch to using that (once it's merged):
>
> * struct drvdata_req_params - driver data request parameters
> * @optional: if true it is not a hard requirement by the caller that this
> * file be present. An error will not be recorded if the file is not
> * found.
>
> Michal, do you mind if I'll add more info to the commit log and submit th=
is RFC
> as a proper patch? It still seems to apply and work just fine.
I don't mind :)
Micha=C5=82
^ permalink raw reply
* Re: [PATCH v3] rt2x00: rt2800lib: add support for RT3352 with 20MHz crystal
From: Stanislaw Gruszka @ 2017-01-20 13:16 UTC (permalink / raw)
To: Daniel Golle
Cc: linux-wireless, Johannes Berg, roman, michel.stempin, c.mignanti,
evaxige, Kalle Valo, Felix Fietkau, John Crispin, Gabor Juhos
In-Reply-To: <20170119234239.GA22196@makrotopia.org>
Hi Daniel
On Fri, Jan 20, 2017 at 12:42:44AM +0100, Daniel Golle wrote:
> +int rt2800_probe_clk(struct rt2x00_dev *rt2x00dev)
> +{
> + struct hw_mode_spec *spec = &rt2x00dev->spec;
> + struct clk *clk = clk_get(rt2x00dev->dev, NULL);
> +
> + if (IS_ERR(clk))
> + return PTR_ERR(clk);
> +
> + if (clk_get_rate(clk) == 20000000)
> + spec->clk_is_20mhz = 1;
> +
> + return 0;
> +}
> +
> int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
> {
> int retval;
> @@ -7864,6 +7903,15 @@ int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
> rt2800_register_write(rt2x00dev, GPIO_CTRL, reg);
>
> /*
> + * Probe SoC clock.
> + */
> + if (rt2x00_is_soc(rt2x00dev)) {
> + retval = rt2800_probe_clk(rt2x00dev);
> + if (retval)
> + return retval;
> + }
<snip>
> @@ -415,6 +416,7 @@ struct hw_mode_spec {
> const struct channel_info *channels_info;
>
> struct ieee80211_sta_ht_cap ht;
> + int clk_is_20mhz;
I dislike adding this variable to structure that is intended to describe
wireless capabilities. Additionally we do not actually "probe" the
clock but just read it value from rt2x00dev->dev, this can be handled
better. I'll post different patch reading clk and on top of if this
patch and "add support for RT5350 WiSoC" .
Regards
Stanislaw
^ permalink raw reply
* Re: [PATCH v3] rt2x00: add support for RT5350 WiSoC
From: Stanislaw Gruszka @ 2017-01-20 13:19 UTC (permalink / raw)
To: Daniel Golle
Cc: linux-wireless, Johannes Berg, roman, michel.stempin, c.mignanti,
evaxige, Kalle Valo, Felix Fietkau, John Crispin, Gabor Juhos
In-Reply-To: <20170119133834.GA17398@makrotopia.org>
On Thu, Jan 19, 2017 at 02:38:45PM +0100, Daniel Golle wrote:
> From: Michel Stempin <michel.stempin@wanadoo.fr>
>
> Support for the RT5350 WiSoC was added to OpenWrt after having a
> lengthy debate about the legality of the original submission, see
> https://lists.openwrt.org/pipermail/openwrt-devel/2013-January/018224.html
> MTK/Ralink Acked replied and says we can merge this patch under the GPL.
> https://dev.openwrt.org/changeset/36177
>
> Signed-off-by: Serge Vasilugin <vasilugin@yandex.ru>
> Tested-by: Michel Stempin <michel.stempin@wanadoo.fr>
> Acked-by: John Crispin <blogic@openwrt.org>
> [daniel@makrotopia.org: added commit message, cleaned up code]
>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Patch is mark as from Michel but we have not sign off from Michel,
however after looking on the link we can find out that patch
was originally from Serge, from whom we have sign-off. I'll correct
that.
Stanislaw
^ permalink raw reply
* [PATCH v4 3/3] rt2x00: add support for RT5350 WiSoC
From: Stanislaw Gruszka @ 2017-01-20 13:28 UTC (permalink / raw)
To: linux-wireless
Cc: Helmut Schaa, Daniel Golle, Gabor Juhos, Serge Vasilugin,
Mathias Kresin, Michel Stempin, John Crispin
In-Reply-To: <1484918906-21856-1-git-send-email-sgruszka@redhat.com>
From: Serge Vasilugin <vasilugin@yandex.ru>
Support for the RT5350 WiSoC was added to OpenWrt after having a
lengthy debate about the legality of the original submission, see
https://lists.openwrt.org/pipermail/openwrt-devel/2013-January/018224.html
MTK/Ralink Acked replied and says we can merge this patch under the GPL.
https://dev.openwrt.org/changeset/36177
Signed-off-by: Serge Vasilugin <vasilugin@yandex.ru>
Tested-by: Michel Stempin <michel.stempin@wanadoo.fr>
Acked-by: John Crispin <blogic@openwrt.org>
[daniel@makrotopia.org: added commit message, cleaned up code]
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
drivers/net/wireless/ralink/rt2x00/rt2800.h | 1 +
drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 125 +++++++++++++++++++++++--
drivers/net/wireless/ralink/rt2x00/rt2x00.h | 1 +
3 files changed, 120 insertions(+), 7 deletions(-)
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800.h b/drivers/net/wireless/ralink/rt2x00/rt2800.h
index 1809690..256496b 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
@@ -72,6 +72,7 @@
#define RF5592 0x000f
#define RF3070 0x3070
#define RF3290 0x3290
+#define RF5350 0x5350
#define RF5360 0x5360
#define RF5362 0x5362
#define RF5370 0x5370
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 5ae2950..755c093 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -2763,6 +2763,13 @@ static void rt2800_config_channel_rf53xx(struct rt2x00_dev *rt2x00dev,
rt2800_rfcsr_write(rt2x00dev, 59,
r59_non_bt[idx]);
+ } else if (rt2x00_rt(rt2x00dev, RT5350)) {
+ static const char r59_non_bt[] = {0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0a,
+ 0x0a, 0x09, 0x08, 0x07, 0x07, 0x06};
+
+ rt2800_rfcsr_write(rt2x00dev, 59,
+ r59_non_bt[idx]);
}
}
}
@@ -3200,6 +3207,7 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
rt2800_config_channel_rf3322(rt2x00dev, conf, rf, info);
break;
case RF3070:
+ case RF5350:
case RF5360:
case RF5362:
case RF5370:
@@ -3218,6 +3226,7 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
if (rt2x00_rf(rt2x00dev, RF3070) ||
rt2x00_rf(rt2x00dev, RF3290) ||
rt2x00_rf(rt2x00dev, RF3322) ||
+ rt2x00_rf(rt2x00dev, RF5350) ||
rt2x00_rf(rt2x00dev, RF5360) ||
rt2x00_rf(rt2x00dev, RF5362) ||
rt2x00_rf(rt2x00dev, RF5370) ||
@@ -3475,7 +3484,8 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
/*
* Clear update flag
*/
- if (rt2x00_rt(rt2x00dev, RT3352)) {
+ if (rt2x00_rt(rt2x00dev, RT3352) ||
+ rt2x00_rt(rt2x00dev, RT5350)) {
rt2800_bbp_read(rt2x00dev, 49, &bbp);
rt2x00_set_field8(&bbp, BBP49_UPDATE_FLAG, 0);
rt2800_bbp_write(rt2x00dev, 49, bbp);
@@ -4356,6 +4366,7 @@ void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev)
case RF3053:
case RF3070:
case RF3290:
+ case RF5350:
case RF5360:
case RF5362:
case RF5370:
@@ -4738,6 +4749,8 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000404);
rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00000000);
rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000);
+ } else if (rt2x00_rt(rt2x00dev, RT5350)) {
+ rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000404);
} else {
rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000000);
rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00080606);
@@ -5383,9 +5396,13 @@ static void rt2800_init_bbp_3352(struct rt2x00_dev *rt2x00dev)
rt2800_bbp_write(rt2x00dev, 82, 0x62);
- rt2800_bbp_write(rt2x00dev, 83, 0x6a);
-
- rt2800_bbp_write(rt2x00dev, 84, 0x99);
+ if (rt2x00_rt(rt2x00dev, RT5350)) {
+ rt2800_bbp_write(rt2x00dev, 83, 0x7a);
+ rt2800_bbp_write(rt2x00dev, 84, 0x9a);
+ } else {
+ rt2800_bbp_write(rt2x00dev, 83, 0x6a);
+ rt2800_bbp_write(rt2x00dev, 84, 0x99);
+ }
rt2800_bbp_write(rt2x00dev, 86, 0x38);
@@ -5399,9 +5416,13 @@ static void rt2800_init_bbp_3352(struct rt2x00_dev *rt2x00dev)
rt2800_bbp_write(rt2x00dev, 104, 0x92);
- rt2800_bbp_write(rt2x00dev, 105, 0x34);
-
- rt2800_bbp_write(rt2x00dev, 106, 0x05);
+ if (rt2x00_rt(rt2x00dev, RT5350)) {
+ rt2800_bbp_write(rt2x00dev, 105, 0x3c);
+ rt2800_bbp_write(rt2x00dev, 106, 0x03);
+ } else {
+ rt2800_bbp_write(rt2x00dev, 105, 0x34);
+ rt2800_bbp_write(rt2x00dev, 106, 0x05);
+ }
rt2800_bbp_write(rt2x00dev, 120, 0x50);
@@ -5426,6 +5447,16 @@ static void rt2800_init_bbp_3352(struct rt2x00_dev *rt2x00dev)
rt2800_bbp_write(rt2x00dev, 143, 0xa2);
rt2800_bbp_write(rt2x00dev, 148, 0xc8);
+
+ if (rt2x00_rt(rt2x00dev, RT5350)) {
+ /* Antenna Software OFDM */
+ rt2800_bbp_write(rt2x00dev, 150, 0x40);
+ /* Antenna Software CCK */
+ rt2800_bbp_write(rt2x00dev, 151, 0x30);
+ rt2800_bbp_write(rt2x00dev, 152, 0xa3);
+ /* Clear previously selected antenna */
+ rt2800_bbp_write(rt2x00dev, 154, 0);
+ }
}
static void rt2800_init_bbp_3390(struct rt2x00_dev *rt2x00dev)
@@ -5726,6 +5757,7 @@ static void rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)
rt2800_init_bbp_3290(rt2x00dev);
break;
case RT3352:
+ case RT5350:
rt2800_init_bbp_3352(rt2x00dev);
break;
case RT3390:
@@ -6536,6 +6568,76 @@ static void rt2800_init_rfcsr_3593(struct rt2x00_dev *rt2x00dev)
/* TODO: enable stream mode support */
}
+static void rt2800_init_rfcsr_5350(struct rt2x00_dev *rt2x00dev)
+{
+ rt2800_rfcsr_write(rt2x00dev, 0, 0xf0);
+ rt2800_rfcsr_write(rt2x00dev, 1, 0x23);
+ rt2800_rfcsr_write(rt2x00dev, 2, 0x50);
+ rt2800_rfcsr_write(rt2x00dev, 3, 0x08);
+ rt2800_rfcsr_write(rt2x00dev, 4, 0x49);
+ rt2800_rfcsr_write(rt2x00dev, 5, 0x10);
+ rt2800_rfcsr_write(rt2x00dev, 6, 0xe0);
+ rt2800_rfcsr_write(rt2x00dev, 7, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 8, 0xf1);
+ rt2800_rfcsr_write(rt2x00dev, 9, 0x02);
+ rt2800_rfcsr_write(rt2x00dev, 10, 0x53);
+ rt2800_rfcsr_write(rt2x00dev, 11, 0x4a);
+ rt2800_rfcsr_write(rt2x00dev, 12, 0x46);
+ if (rt2800_clk_is_20mhz(rt2x00dev))
+ rt2800_rfcsr_write(rt2x00dev, 13, 0x1f);
+ else
+ rt2800_rfcsr_write(rt2x00dev, 13, 0x9f);
+ rt2800_rfcsr_write(rt2x00dev, 14, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 15, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 16, 0xc0);
+ rt2800_rfcsr_write(rt2x00dev, 18, 0x03);
+ rt2800_rfcsr_write(rt2x00dev, 19, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 20, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 21, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 22, 0x20);
+ rt2800_rfcsr_write(rt2x00dev, 23, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 24, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 25, 0x80);
+ rt2800_rfcsr_write(rt2x00dev, 26, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 27, 0x03);
+ rt2800_rfcsr_write(rt2x00dev, 28, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 29, 0xd0);
+ rt2800_rfcsr_write(rt2x00dev, 30, 0x10);
+ rt2800_rfcsr_write(rt2x00dev, 31, 0x80);
+ rt2800_rfcsr_write(rt2x00dev, 32, 0x80);
+ rt2800_rfcsr_write(rt2x00dev, 33, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 34, 0x07);
+ rt2800_rfcsr_write(rt2x00dev, 35, 0x12);
+ rt2800_rfcsr_write(rt2x00dev, 36, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 37, 0x08);
+ rt2800_rfcsr_write(rt2x00dev, 38, 0x85);
+ rt2800_rfcsr_write(rt2x00dev, 39, 0x1b);
+ rt2800_rfcsr_write(rt2x00dev, 40, 0x0b);
+ rt2800_rfcsr_write(rt2x00dev, 41, 0xbb);
+ rt2800_rfcsr_write(rt2x00dev, 42, 0xd5);
+ rt2800_rfcsr_write(rt2x00dev, 43, 0x9b);
+ rt2800_rfcsr_write(rt2x00dev, 44, 0x0c);
+ rt2800_rfcsr_write(rt2x00dev, 45, 0xa6);
+ rt2800_rfcsr_write(rt2x00dev, 46, 0x73);
+ rt2800_rfcsr_write(rt2x00dev, 47, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 48, 0x10);
+ rt2800_rfcsr_write(rt2x00dev, 49, 0x80);
+ rt2800_rfcsr_write(rt2x00dev, 50, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 51, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 52, 0x38);
+ rt2800_rfcsr_write(rt2x00dev, 53, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 54, 0x38);
+ rt2800_rfcsr_write(rt2x00dev, 55, 0x43);
+ rt2800_rfcsr_write(rt2x00dev, 56, 0x82);
+ rt2800_rfcsr_write(rt2x00dev, 57, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 58, 0x39);
+ rt2800_rfcsr_write(rt2x00dev, 59, 0x0b);
+ rt2800_rfcsr_write(rt2x00dev, 60, 0x45);
+ rt2800_rfcsr_write(rt2x00dev, 61, 0xd1);
+ rt2800_rfcsr_write(rt2x00dev, 62, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 63, 0x00);
+}
+
static void rt2800_init_rfcsr_5390(struct rt2x00_dev *rt2x00dev)
{
rt2800_rf_init_calibration(rt2x00dev, 2);
@@ -6773,6 +6875,9 @@ static void rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
case RT3593:
rt2800_init_rfcsr_3593(rt2x00dev);
break;
+ case RT5350:
+ rt2800_init_rfcsr_5350(rt2x00dev);
+ break;
case RT5390:
rt2800_init_rfcsr_5390(rt2x00dev);
break;
@@ -7152,6 +7257,8 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
rt2800_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, &rf);
else if (rt2x00_rt(rt2x00dev, RT3352))
rf = RF3322;
+ else if (rt2x00_rt(rt2x00dev, RT5350))
+ rf = RF5350;
else
rf = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RF_TYPE);
@@ -7170,6 +7277,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
case RF3290:
case RF3320:
case RF3322:
+ case RF5350:
case RF5360:
case RF5362:
case RF5370:
@@ -7673,6 +7781,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
case RF3290:
case RF3320:
case RF3322:
+ case RF5350:
case RF5360:
case RF5362:
case RF5370:
@@ -7809,6 +7918,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
case RF3053:
case RF3070:
case RF3290:
+ case RF5350:
case RF5360:
case RF5362:
case RF5370:
@@ -7849,6 +7959,7 @@ static int rt2800_probe_rt(struct rt2x00_dev *rt2x00dev)
case RT3390:
case RT3572:
case RT3593:
+ case RT5350:
case RT5390:
case RT5392:
case RT5592:
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00.h b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
index b59e721..ea299c4 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
@@ -170,6 +170,7 @@ struct rt2x00_chip {
#define RT3572 0x3572
#define RT3593 0x3593
#define RT3883 0x3883 /* WSOC */
+#define RT5350 0x5350 /* WSOC 2.4GHz */
#define RT5390 0x5390 /* 2.4GHz */
#define RT5392 0x5392 /* 2.4GHz */
#define RT5592 0x5592
--
1.8.3.1
^ permalink raw reply related
* [PATCH v4 0/3] rt2x00: RT5350 support
From: Stanislaw Gruszka @ 2017-01-20 13:28 UTC (permalink / raw)
To: linux-wireless
Cc: Helmut Schaa, Daniel Golle, Gabor Juhos, Serge Vasilugin,
Mathias Kresin, Michel Stempin, John Crispin
Repost patches from Daniel with updated clock handling and
correct author of RT5350 patch.
Note I did not test patches on SOC devices, but getting
clock frequency is simple and should be trouble-free.
Daniel Golle (1):
rt2x00: rt2800lib: add support for RT3352 with 20MHz crystal
Serge Vasilugin (1):
rt2x00: add support for RT5350 WiSoC
Stanislaw Gruszka (1):
rt2x00: add copy of clk for soc devices
drivers/net/wireless/ralink/rt2x00/rt2800.h | 1 +
drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 156 +++++++++++++++++++++++--
drivers/net/wireless/ralink/rt2x00/rt2x00.h | 5 +
drivers/net/wireless/ralink/rt2x00/rt2x00soc.c | 1 +
4 files changed, 155 insertions(+), 8 deletions(-)
--
1.8.3.1
^ permalink raw reply
* [PATCH v4 1/3] rt2x00: add copy of clk for soc devices
From: Stanislaw Gruszka @ 2017-01-20 13:28 UTC (permalink / raw)
To: linux-wireless
Cc: Helmut Schaa, Daniel Golle, Gabor Juhos, Serge Vasilugin,
Mathias Kresin, Michel Stempin, John Crispin
In-Reply-To: <1484918906-21856-1-git-send-email-sgruszka@redhat.com>
Since clk_get() is not trivial add copy of clk pointer to rt2x00dev
for System On Chip devices and initialize it on probe routine.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
drivers/net/wireless/ralink/rt2x00/rt2x00.h | 4 ++++
drivers/net/wireless/ralink/rt2x00/rt2x00soc.c | 1 +
2 files changed, 5 insertions(+)
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00.h b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
index bea7ac3..b59e721 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
@@ -39,6 +39,7 @@
#include <linux/hrtimer.h>
#include <linux/average.h>
#include <linux/usb.h>
+#include <linux/clk.h>
#include <net/mac80211.h>
@@ -1011,6 +1012,9 @@ struct rt2x00_dev {
unsigned int extra_tx_headroom;
struct usb_anchor *anchor;
+
+ /* Clock for System On Chip devices. */
+ struct clk *clk;
};
struct rt2x00_bar_list_entry {
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00soc.c b/drivers/net/wireless/ralink/rt2x00/rt2x00soc.c
index 69a0cda..362f9d3 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00soc.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00soc.c
@@ -92,6 +92,7 @@ int rt2x00soc_probe(struct platform_device *pdev, const struct rt2x00_ops *ops)
rt2x00dev->hw = hw;
rt2x00dev->irq = platform_get_irq(pdev, 0);
rt2x00dev->name = pdev->dev.driver->name;
+ rt2x00dev->clk = clk_get(&pdev->dev);
rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC);
--
1.8.3.1
^ permalink raw reply related
* [PATCH v4 2/3] rt2x00: rt2800lib: add support for RT3352 with 20MHz crystal
From: Stanislaw Gruszka @ 2017-01-20 13:28 UTC (permalink / raw)
To: linux-wireless
Cc: Helmut Schaa, Daniel Golle, Gabor Juhos, Serge Vasilugin,
Mathias Kresin, Michel Stempin, John Crispin
In-Reply-To: <1484918906-21856-1-git-send-email-sgruszka@redhat.com>
From: Daniel Golle <daniel@makrotopia.org>
On Rt3352 the driver needs to know the frequency of an external
crystal which can be either 40 MHz (as on all other WiSoCs until now)
or 20 MHz.
Get the clock attached by ramips WiSoC platform code which probes
SYSC_REG_SYSCFG (added by John Crispin in commit 6ac8579b96e3b) and
introduce a new flag clk_is_20mhz in struct hw_mode_spec to make the
driver aware and use either 40 MHz or 20 MHz specific rf_vals on those
WiSoC platforms.
The introduced support for boards with a 20 MHz crystal is also needed
for RT5350.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 31 +++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 8ea844d..5ae2950 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -1935,6 +1935,11 @@ static void rt2800_config_lna_gain(struct rt2x00_dev *rt2x00dev,
rt2x00dev->lna_gain = lna_gain;
}
+static inline bool rt2800_clk_is_20mhz(struct rt2x00_dev *rt2x00dev)
+{
+ return clk_get_rate(rt2x00dev->clk) == 20000000;
+}
+
#define FREQ_OFFSET_BOUND 0x5f
static void rt2800_freq_cal_mode1(struct rt2x00_dev *rt2x00dev)
@@ -7426,6 +7431,27 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
{173, 0x61, 0, 9},
};
+/*
+ * RF value list for rt3xxx with Xtal20MHz
+ * Supports: 2.4 GHz (all) (RF3322)
+ */
+static const struct rf_channel rf_vals_3x_xtal20[] = {
+ {1, 0xE2, 2, 0x14},
+ {2, 0xE3, 2, 0x14},
+ {3, 0xE4, 2, 0x14},
+ {4, 0xE5, 2, 0x14},
+ {5, 0xE6, 2, 0x14},
+ {6, 0xE7, 2, 0x14},
+ {7, 0xE8, 2, 0x14},
+ {8, 0xE9, 2, 0x14},
+ {9, 0xEA, 2, 0x14},
+ {10, 0xEB, 2, 0x14},
+ {11, 0xEC, 2, 0x14},
+ {12, 0xED, 2, 0x14},
+ {13, 0xEE, 2, 0x14},
+ {14, 0xF0, 2, 0x18},
+};
+
static const struct rf_channel rf_vals_5592_xtal20[] = {
/* Channel, N, K, mod, R */
{1, 482, 4, 10, 3},
@@ -7654,7 +7680,10 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
case RF5390:
case RF5392:
spec->num_channels = 14;
- spec->channels = rf_vals_3x;
+ if (rt2800_clk_is_20mhz(rt2x00dev))
+ spec->channels = rf_vals_3x_xtal20;
+ else
+ spec->channels = rf_vals_3x;
break;
case RF3052:
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH v4 1/3] rt2x00: add copy of clk for soc devices
From: Daniel Golle @ 2017-01-20 14:13 UTC (permalink / raw)
To: Stanislaw Gruszka
Cc: linux-wireless, Helmut Schaa, Gabor Juhos, Serge Vasilugin,
Mathias Kresin, Michel Stempin, John Crispin
In-Reply-To: <1484918906-21856-2-git-send-email-sgruszka@redhat.com>
On Fri, Jan 20, 2017 at 02:28:24PM +0100, Stanislaw Gruszka wrote:
> Since clk_get() is not trivial add copy of clk pointer to rt2x00dev
> for System On Chip devices and initialize it on probe routine.
>
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Daniel Golle <daniel@makrotopia.org>
^ permalink raw reply
* RE: [PATCH] rtlwifi: rtl8192x: Enabling and disabling hardware interrupts after enabling local irq flags
From: Bharat Kumar Gogada @ 2017-01-20 14:14 UTC (permalink / raw)
To: Larry Finger, chaoming_li@realsil.com.cn,
linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: kvalo@codeaurora.org, netdev@vger.kernel.org, Ravikiran Gummaluri
In-Reply-To: <b2e783f6-fa09-e287-8119-266299cdae22@lwfinger.net>
> On 01/19/2017 04:14 AM, Bharat Kumar Gogada wrote:
> > -Realtek 8192CE chipset maintains local irq flags after enabling/disabl=
ing
> > hardware interrupts.
> > -Hardware interrupts are enabled before enabling the local irq
> > flags(these flags are being checked in interrupt handler),
> > leading to race condition on some RP, where the irq line between
> > bridge and GIC goes high at ASSERT_INTx and goes low only
> > at DEASSERT_INTx. In this kind of RP by the time ASSERT_INTx is seen
> > irq_enable flag is still set to false, resulting in continuous
> > interrupts seen by CPU as DEASSERT_INTx cannot be sent since
> > flag is still false and making CPU stall.
> > -Changing the sequence of setting these irq flags.
> >
> > Signed-off-by: Bharat Kumar Gogada <bharatku@xilinx.com>
> > ---
>=20
> This patch should be enhanced with the smb_xx() calls as suggested by by =
Lino.
>=20
> The subject should be changed. I would suggest something like "rtlwifi:
> rtl8192ce: Prevent race condition when enabling interrupts", as it explai=
ns the
> condition you are preventing.
>=20
> The other PCI drivers also have the same problem. Do you want to prepare =
the
> patches, or should I do it?
>=20
Thanks Larry. Please send out the patches adding the above enhancements sug=
gested by Lino.
Bharat
^ permalink raw reply
* [RFC 1/2] ath9k: Add tx descriptor flag to corrupt frame fcs
From: Wojciech Dubowik @ 2017-01-20 14:29 UTC (permalink / raw)
To: linux-wireless; +Cc: kvalo, Wojciech Dubowik
In-Reply-To: <1484922570-23659-1-git-send-email-Wojciech.Dubowik@neratec.com>
When this flag is present the transmitted frame fcs field
bits are inverted in hardware so the frame is being treated
as corrupted on the recevieng node.
It's used by frame corruption simulator coming on the following
patch.
Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
---
drivers/net/wireless/ath/ath9k/ar9003_mac.c | 3 ++-
drivers/net/wireless/ath/ath9k/mac.h | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
index da84b70..0b7fbfd 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
@@ -114,7 +114,8 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
| SM(i->type, AR_FrameType)
| (i->flags & ATH9K_TXDESC_NOACK ? AR_NoAck : 0)
| (i->flags & ATH9K_TXDESC_EXT_ONLY ? AR_ExtOnly : 0)
- | (i->flags & ATH9K_TXDESC_EXT_AND_CTL ? AR_ExtAndCtl : 0);
+ | (i->flags & ATH9K_TXDESC_EXT_AND_CTL ? AR_ExtAndCtl : 0)
+ | (i->flags & ATH9K_TXDESC_CORRUPT_FCS ? AR_CorruptFCS : 0);
ctl17 |= (i->flags & ATH9K_TXDESC_LDPC ? AR_LDPC : 0);
switch (i->aggr) {
diff --git a/drivers/net/wireless/ath/ath9k/mac.h b/drivers/net/wireless/ath/ath9k/mac.h
index 3bab014..1c30dfd 100644
--- a/drivers/net/wireless/ath/ath9k/mac.h
+++ b/drivers/net/wireless/ath/ath9k/mac.h
@@ -265,6 +265,8 @@ struct ath_desc {
#define ATH9K_TXDESC_PAPRD 0x70000
#define ATH9K_TXDESC_PAPRD_S 16
+#define ATH9K_TXDESC_CORRUPT_FCS 0x80000
+
#define ATH9K_RXDESC_INTREQ 0x0020
struct ar5416_desc {
--
2.7.4
^ permalink raw reply related
* [RFC 0/1] ath9k: Frame corruption simulator
From: Wojciech Dubowik @ 2017-01-20 14:29 UTC (permalink / raw)
To: linux-wireless; +Cc: kvalo, Wojciech Dubowik
I have been debugging customer reported timeout and loss of
communication and I have relaized that I don't have such a lossy
environment available in the lab. To speed up debugging I have
written frame corruption simulator which will allow me to
totally loose specific types of packets. I have been mostly
using it with the mask 0x5000 which drops some EAPOL
and deauthentication frames. This way I was able to test better
timeouts and fail paths.
At the moment only management, null function and EAPOL frames
are supported. One can add more if necessary.
Wojciech Dubowik (1):
ath9k: Add frame corruption simulator
drivers/net/wireless/ath/ath9k/Kconfig | 15 +++++
drivers/net/wireless/ath/ath9k/ath9k.h | 7 +++
drivers/net/wireless/ath/ath9k/debug.c | 49 +++++++++++++++
drivers/net/wireless/ath/ath9k/xmit.c | 106 +++++++++++++++++++++++++++++++++
4 files changed, 177 insertions(+)
--
2.7.4
^ permalink raw reply
* [RFC 2/2] ath9k: Add frame corruption simulator
From: Wojciech Dubowik @ 2017-01-20 14:29 UTC (permalink / raw)
To: linux-wireless; +Cc: kvalo, Wojciech Dubowik
In-Reply-To: <1484922570-23659-1-git-send-email-Wojciech.Dubowik@neratec.com>
Add debugfs entries to corrupt specified frame types
by invering fcs field upon transmissionm with given probability.
Select frames to be corrupted.
<ath9k_debugs>/corrupt_fcs_fram_mask:
Bit 16 - Null function
Bit 15 - QoS Null function
Bit 14 - EAPOL
Bit 13 - Action
Bit 12 - Deauthentication
Bit 11 - Authentication
Bit 10 - Disassociation
Bit 9 - ATIM
Bit 8 - Beacon
Bit 5 - Probe response
Bit 4 - Probe request
Bit 3 - Reassociation response
Bit 2 - Reassociation request
Bit 1 - Association response
Bit 0 - Association request
Select corruption probability:
<ath9k_debugs>/corrupt_fcs_prob: 0(0%) to 255(100%)
Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
---
drivers/net/wireless/ath/ath9k/Kconfig | 15 +++++
drivers/net/wireless/ath/ath9k/ath9k.h | 7 ++
drivers/net/wireless/ath/ath9k/debug.c | 51 ++++++++++++++
drivers/net/wireless/ath/ath9k/xmit.c | 117 +++++++++++++++++++++++++++++++++
4 files changed, 190 insertions(+)
diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
index 8f231c6..ca50f0f 100644
--- a/drivers/net/wireless/ath/ath9k/Kconfig
+++ b/drivers/net/wireless/ath/ath9k/Kconfig
@@ -95,6 +95,21 @@ config ATH9K_TX99
be evaluated to meet the RF exposure limits set forth in the
governmental SAR regulations.
+config ATH9K_FRAME_LOSS_SIMULATOR
+ bool "Atheros ath9k frame loss simulator"
+ depends on ATH9K && ATH9K_DEBUGFS && DEBUG_FS
+ default n
+ ---help---
+ Say N. This option should be used only to test fail paths
+ and timeouts by inverting fcs field of selected frames to
+ be transmitted.
+ Which frames are corrupted is marked by bitfield in
+ corrupt_fcs_frame_mask debug entry and probability of
+ of corruption in corrupt_fcs_prob (0-255). Zero means
+ disabled and writing 255 makes all selected frames fail.
+ Management, EAPOL, and Null function frames are
+ supported.
+
config ATH9K_DFS_CERTIFIED
bool "Atheros DFS support for certified platforms"
depends on ATH9K && CFG80211_CERTIFICATION_ONUS
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 331947b..e5ae8f2 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -183,6 +183,9 @@ struct ath_frame_info {
u8 baw_tracked : 1;
u8 tx_power;
enum ath9k_key_type keytype:2;
+#ifdef CONFIG_ATH9K_FRAME_LOSS_SIMULATOR
+ u8 corrupt_fcs : 1;
+#endif
};
struct ath_rxbuf {
@@ -1087,6 +1090,10 @@ struct ath_softc {
u32 rng_last;
struct task_struct *rng_task;
#endif
+#ifdef CONFIG_ATH9K_FRAME_LOSS_SIMULATOR
+ u16 corrupt_fcs_prob;
+ u32 corrupt_fcs_frame_mask;
+#endif
};
/********/
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 43930c3..15ccf52 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -1315,6 +1315,50 @@ void ath9k_deinit_debug(struct ath_softc *sc)
ath9k_cmn_spectral_deinit_debug(&sc->spec_priv);
}
+#ifdef CONFIG_ATH9K_FRAME_LOSS_SIMULATOR
+static ssize_t read_file_corrupt_fcs_frame_mask(struct file *file,
+ char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct ath_softc *sc = file->private_data;
+ char buf[4];
+ unsigned int len;
+
+ len = sprintf(buf, "0x%08x\n", sc->corrupt_fcs_frame_mask);
+ return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t write_file_corrupt_fcs_frame_mask(struct file *file,
+ const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct ath_softc *sc = file->private_data;
+ unsigned long corrupt_fcs_frame_mask;
+ char buf[32];
+ ssize_t len;
+
+ len = min(count, sizeof(buf) - 1);
+ if (copy_from_user(buf, user_buf, len))
+ return -EFAULT;
+
+ buf[len] = '\0';
+ if (kstrtoul(buf, 0, &corrupt_fcs_frame_mask))
+ return -EINVAL;
+
+ sc->corrupt_fcs_frame_mask = corrupt_fcs_frame_mask;
+
+ return count;
+}
+
+static const struct file_operations fops_corrupt_fcs_frame_mask = {
+ .read = read_file_corrupt_fcs_frame_mask,
+ .write = write_file_corrupt_fcs_frame_mask,
+ .open = simple_open,
+ .owner = THIS_MODULE,
+ .llseek = default_llseek,
+};
+#endif
+
int ath9k_init_debug(struct ath_hw *ah)
{
struct ath_common *common = ath9k_hw_common(ah);
@@ -1402,5 +1446,12 @@ int ath9k_init_debug(struct ath_hw *ah)
debugfs_create_u16("airtime_flags", S_IRUSR | S_IWUSR,
sc->debug.debugfs_phy, &sc->airtime_flags);
+#ifdef CONFIG_ATH9K_FRAME_LOSS_SIMULATOR
+ debugfs_create_u16("corrupt_fcs_prob", S_IRUSR | S_IWUSR,
+ sc->debug.debugfs_phy, &sc->corrupt_fcs_prob);
+ debugfs_create_file("corrupt_fcs_frame_mask", S_IRUSR | S_IWUSR,
+ sc->debug.debugfs_phy, sc,
+ &fops_corrupt_fcs_frame_mask);
+#endif
return 0;
}
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index c35a192..86a7e31 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1443,6 +1443,10 @@ static void ath_tx_fill_desc(struct ath_softc *sc, struct ath_buf *bf,
if (bf->bf_state.bfs_paprd)
info.flags |= (u32) bf->bf_state.bfs_paprd <<
ATH9K_TXDESC_PAPRD_S;
+#ifdef CONFIG_ATH9K_FRAME_LOSS_SIMULATOR
+ if (fi->corrupt_fcs)
+ info.flags |= ATH9K_TXDESC_CORRUPT_FCS;
+#endif
/*
* mac80211 doesn't handle RTS threshold for HT because
@@ -2345,6 +2349,112 @@ static int ath_tx_prepare(struct ieee80211_hw *hw, struct sk_buff *skb,
return 0;
}
+#ifdef CONFIG_ATH9K_FRAME_LOSS_SIMULATOR
+static bool corrupt_frame_fcs(struct ath_softc *sc, struct sk_buff *skb)
+{
+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+ struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+
+ /* Frame loss enable mask */
+ /* Bit 16 - Null function*/
+ /* Bit 15 - QoS Null function*/
+ /* Bit 14 - EAPOL */
+ /* Bit 13 - Action */
+ /* Bit 12 - Deauthentication */
+ /* Bit 11 - Authentication */
+ /* Bit 10 - Disassociation */
+ /* Bit 9 - ATIM */
+ /* Bit 8 - Beacon */
+ /* Bit 5 - Probe response */
+ /* Bit 4 - Probe request */
+ /* Bit 3 - Reassociation response */
+ /* Bit 2 - Reassociation request */
+ /* Bit 1 - Association response */
+ /* Bit 0 - Association request */
+
+ /* Frame loss probability is 0(0%) to 255(100%) */
+ if (sc->corrupt_fcs_prob &&
+ get_random_int() % 256 <= sc->corrupt_fcs_prob) {
+ u16 fctl_stype =
+ le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_STYPE;
+
+ if (((1 << 16) & sc->corrupt_fcs_frame_mask) &&
+ ieee80211_is_nullfunc(hdr->frame_control)) {
+ ath_info(common, "Null function frame corrupted\n");
+ return true;
+ }
+ if (((1 << 15) & sc->corrupt_fcs_frame_mask) &&
+ ieee80211_is_qos_nullfunc(hdr->frame_control)) {
+ ath_info(common, "QOS Null function frame corrupted\n");
+ return true;
+ }
+ if (((1 << 14) & sc->corrupt_fcs_frame_mask) &&
+ (info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO)) {
+ ath_info(common, "EAPOL frame corrupted\n");
+ return true;
+ }
+ if (ieee80211_is_mgmt(hdr->frame_control) &&
+ ((1 << (fctl_stype >> 4)) & sc->corrupt_fcs_frame_mask)) {
+ switch (fctl_stype) {
+ case IEEE80211_STYPE_ASSOC_REQ:
+ ath_info(common,
+ "Association request corrupted\n");
+ break;
+ case IEEE80211_STYPE_ASSOC_RESP:
+ ath_info(common,
+ "Association response corrupted\n");
+ break;
+ case IEEE80211_STYPE_REASSOC_REQ:
+ ath_info(common,
+ "Re-association request corrupted\n");
+ break;
+ case IEEE80211_STYPE_REASSOC_RESP:
+ ath_info(common,
+ "Re-association response corrupted\n");
+ break;
+ case IEEE80211_STYPE_PROBE_REQ:
+ ath_info(common,
+ "Probe request corrupted\n");
+ break;
+ case IEEE80211_STYPE_PROBE_RESP:
+ ath_info(common,
+ "Probe response corrupted\n");
+ break;
+ case IEEE80211_STYPE_BEACON:
+ ath_info(common,
+ "Beacon corrupted\n");
+ break;
+ case IEEE80211_STYPE_ATIM:
+ ath_info(common,
+ "ATIM frame corrupted\n");
+ break;
+ case IEEE80211_STYPE_DISASSOC:
+ ath_info(common,
+ "Disassociation frame corrupted\n");
+ break;
+ case IEEE80211_STYPE_AUTH:
+ ath_info(common,
+ "Authentication frame corrupted\n");
+ break;
+ case IEEE80211_STYPE_DEAUTH:
+ ath_info(common,
+ "Deauthentication frame corrupted\n");
+ break;
+ case IEEE80211_STYPE_ACTION:
+ ath_info(common,
+ "Action frame corrupted\n");
+ break;
+
+ default:
+ return false;
+ }
+ return true;
+ }
+ }
+ return false;
+}
+#endif
/* Upon failure caller should free skb */
int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
@@ -2363,6 +2473,9 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
struct ath_buf *bf;
bool ps_resp;
int q, ret;
+#ifdef CONFIG_ATH9K_FRAME_LOSS_SIMULATOR
+ bool corrupt_fcs = corrupt_frame_fcs(sc, skb);
+#endif
if (vif)
avp = (void *)vif->drv_priv;
@@ -2373,6 +2486,10 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
if (ret)
return ret;
+#ifdef CONFIG_ATH9K_FRAME_LOSS_SIMULATOR
+ fi->corrupt_fcs = corrupt_fcs;
+#endif
+
hdr = (struct ieee80211_hdr *) skb->data;
/*
* At this point, the vif, hw_key and sta pointers in the tx control
--
2.7.4
^ permalink raw reply related
* Re: [PATCH v4 0/3] rt2x00: RT5350 support
From: Daniel Golle @ 2017-01-20 14:32 UTC (permalink / raw)
To: Stanislaw Gruszka
Cc: linux-wireless, Helmut Schaa, Gabor Juhos, Serge Vasilugin,
Mathias Kresin, Michel Stempin, John Crispin
In-Reply-To: <1484918906-21856-1-git-send-email-sgruszka@redhat.com>
Hi Stanislaw,
On Fri, Jan 20, 2017 at 02:28:23PM +0100, Stanislaw Gruszka wrote:
> Repost patches from Daniel with updated clock handling and
> correct author of RT5350 patch.
>
> Note I did not test patches on SOC devices, but getting
> clock frequency is simple and should be trouble-free.
Thanks a lot for handling this!
And big thanks to everyone involved for reviewing a smelly pile of
patches we had rotting here for half a decade...
Would you like me to re-work and re-submit the remaining patches needed
to support RT3883 and RF3853?
Otherwise, the next thing I'd have in mind would be to add device-tree
bindings to handle in-flash EEPROM loading, see the patches 60[2-9]* in
https://git.lede-project.org/?p=source.git;a=tree;f=package/kernel/mac80211/patches
Imho having only support for MTD partitions and skip support for
requesting firmware files from userspace for now would be the cleanest
way towards proper WiSoC support in vanilla kernels.
Obviously our existing patches need to be reworked and stuff needs to
be added to Documentation/devicetree/bindings.
Support for non-device-tree legacy platforms which need platform_data
and legacy EEPROM loading mechanism can remain a local patch in our
tree until those will no longer be needed.
Does everybody agree with this general direction?
John, Mathias: Are you going to rework and upstream your work to
support loading in-flash EEPROM yourself our would you like me to give
it a shot?
Cheers
Daniel
>
> Daniel Golle (1):
> rt2x00: rt2800lib: add support for RT3352 with 20MHz crystal
>
> Serge Vasilugin (1):
> rt2x00: add support for RT5350 WiSoC
>
> Stanislaw Gruszka (1):
> rt2x00: add copy of clk for soc devices
>
> drivers/net/wireless/ralink/rt2x00/rt2800.h | 1 +
> drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 156 +++++++++++++++++++++++--
> drivers/net/wireless/ralink/rt2x00/rt2x00.h | 5 +
> drivers/net/wireless/ralink/rt2x00/rt2x00soc.c | 1 +
> 4 files changed, 155 insertions(+), 8 deletions(-)
>
> --
> 1.8.3.1
>
^ permalink raw reply
* Re: [RFC 0/1] ath9k: Frame corruption simulator
From: Ben Greear @ 2017-01-20 14:45 UTC (permalink / raw)
To: Wojciech Dubowik, linux-wireless; +Cc: kvalo
In-Reply-To: <1484922570-23659-1-git-send-email-Wojciech.Dubowik@neratec.com>
On 01/20/2017 06:29 AM, Wojciech Dubowik wrote:
> I have been debugging customer reported timeout and loss of
> communication and I have relaized that I don't have such a lossy
> environment available in the lab. To speed up debugging I have
> written frame corruption simulator which will allow me to
> totally loose specific types of packets. I have been mostly
> using it with the mask 0x5000 which drops some EAPOL
> and deauthentication frames. This way I was able to test better
> timeouts and fail paths.
> At the moment only management, null function and EAPOL frames
> are supported. One can add more if necessary.
Would it be worth having a unique percentage configurable for each
of the selected packet types?
How about moving this up into mac80211 so other drivers could
be supported as well? Couldn't you just drop the frames instead
of corrupting their checksum? That would work with things like ath10k
as well.
I would like to have something like this, but with the added ability
to corrupt specific things like information-elements in management
frames to better test the receiver's packet parsing and error checking
logic. For this feature, checksum would not be corrupted.
Thanks,
Ben
>
> Wojciech Dubowik (1):
> ath9k: Add frame corruption simulator
>
> drivers/net/wireless/ath/ath9k/Kconfig | 15 +++++
> drivers/net/wireless/ath/ath9k/ath9k.h | 7 +++
> drivers/net/wireless/ath/ath9k/debug.c | 49 +++++++++++++++
> drivers/net/wireless/ath/ath9k/xmit.c | 106 +++++++++++++++++++++++++++++++++
> 4 files changed, 177 insertions(+)
>
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply
* Re: [RFC 2/2] ath9k: Add frame corruption simulator
From: Kalle Valo @ 2017-01-20 15:07 UTC (permalink / raw)
To: Wojciech Dubowik; +Cc: linux-wireless
In-Reply-To: <1484922570-23659-3-git-send-email-Wojciech.Dubowik@neratec.com>
Wojciech Dubowik <Wojciech.Dubowik@neratec.com> writes:
> Add debugfs entries to corrupt specified frame types
> by invering fcs field upon transmissionm with given probability.
>
> Select frames to be corrupted.
> <ath9k_debugs>/corrupt_fcs_fram_mask:
> Bit 16 - Null function
> Bit 15 - QoS Null function
> Bit 14 - EAPOL
> Bit 13 - Action
> Bit 12 - Deauthentication
> Bit 11 - Authentication
> Bit 10 - Disassociation
> Bit 9 - ATIM
> Bit 8 - Beacon
> Bit 5 - Probe response
> Bit 4 - Probe request
> Bit 3 - Reassociation response
> Bit 2 - Reassociation request
> Bit 1 - Association response
> Bit 0 - Association request
>
> Select corruption probability:
> <ath9k_debugs>/corrupt_fcs_prob: 0(0%) to 255(100%)
>
> Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
> ---
> drivers/net/wireless/ath/ath9k/Kconfig | 15 +++++
> drivers/net/wireless/ath/ath9k/ath9k.h | 7 ++
> drivers/net/wireless/ath/ath9k/debug.c | 51 ++++++++++++++
> drivers/net/wireless/ath/ath9k/xmit.c | 117 +++++++++++++++++++++++++++++++++
> 4 files changed, 190 insertions(+)
>
> diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
> index 8f231c6..ca50f0f 100644
> --- a/drivers/net/wireless/ath/ath9k/Kconfig
> +++ b/drivers/net/wireless/ath/ath9k/Kconfig
> @@ -95,6 +95,21 @@ config ATH9K_TX99
> be evaluated to meet the RF exposure limits set forth in the
> governmental SAR regulations.
>
> +config ATH9K_FRAME_LOSS_SIMULATOR
> + bool "Atheros ath9k frame loss simulator"
> + depends on ATH9K && ATH9K_DEBUGFS && DEBUG_FS
> + default n
> + ---help---
> + Say N. This option should be used only to test fail paths
> + and timeouts by inverting fcs field of selected frames to
> + be transmitted.
> + Which frames are corrupted is marked by bitfield in
> + corrupt_fcs_frame_mask debug entry and probability of
> + of corruption in corrupt_fcs_prob (0-255). Zero means
> + disabled and writing 255 makes all selected frames fail.
> + Management, EAPOL, and Null function frames are
> + supported.
Why a separate Kconfig option? Does this significantly increase memory
consumption or something? I ask because we should be conservative when
adding new Kconfig options.
--
Kalle Valo
^ permalink raw reply
* Re: [RFC 2/2] ath9k: Add frame corruption simulator
From: Wojciech Dubowik @ 2017-01-20 15:13 UTC (permalink / raw)
To: Kalle Valo; +Cc: linux-wireless
In-Reply-To: <8760l9n51q.fsf@kamboji.qca.qualcomm.com>
On 20/01/17 16:07, Kalle Valo wrote:
>> +config ATH9K_FRAME_LOSS_SIMULATOR
>> + bool "Atheros ath9k frame loss simulator"
>> + depends on ATH9K && ATH9K_DEBUGFS && DEBUG_FS
>> + default n
>> + ---help---
>> + Say N. This option should be used only to test fail paths
>> + and timeouts by inverting fcs field of selected frames to
>> + be transmitted.
>> + Which frames are corrupted is marked by bitfield in
>> + corrupt_fcs_frame_mask debug entry and probability of
>> + of corruption in corrupt_fcs_prob (0-255). Zero means
>> + disabled and writing 255 makes all selected frames fail.
>> + Management, EAPOL, and Null function frames are
>> + supported.
> Why a separate Kconfig option? Does this significantly increase memory
> consumption or something? I ask because we should be conservative when
> adding new Kconfig options.
It shouldn't so I could drop it.
Wojtek
>
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox