linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: David Lin <yu-hao.lin@nxp.com>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"briannorris@chromium.org" <briannorris@chromium.org>,
	"kvalo@kernel.org" <kvalo@kernel.org>,
	"francesco@dolcini.it" <francesco@dolcini.it>,
	Pete Hsieh <tsung-hsien.hsieh@nxp.com>
Subject: Re: [EXT] Re: [PATCH v2] wifi: mwifiex: avoid AP and STA running on different channel
Date: Tue, 10 Sep 2024 10:31:33 +0200	[thread overview]
Message-ID: <ZuAD5fKyKgHPFN8s@pengutronix.de> (raw)
In-Reply-To: <PA4PR04MB963850587C41FF78F4244E3AD19A2@PA4PR04MB9638.eurprd04.prod.outlook.com>

On Tue, Sep 10, 2024 at 08:19:59AM +0000, David Lin wrote:
> > From: Sascha Hauer <s.hauer@pengutronix.de>
> > Sent: Tuesday, September 10, 2024 4:00 PM
> > To: David Lin <yu-hao.lin@nxp.com>
> > Cc: linux-wireless@vger.kernel.org; linux-kernel@vger.kernel.org;
> > briannorris@chromium.org; kvalo@kernel.org; francesco@dolcini.it; Pete
> > Hsieh <tsung-hsien.hsieh@nxp.com>
> > Subject: Re: [EXT] Re: [PATCH v2] wifi: mwifiex: avoid AP and STA running on
> > different channel
> > 
> > Caution: This is an external email. Please take care when clicking links or
> > opening attachments. When in doubt, report the message using the 'Report
> > this email' button
> > 
> > 
> > On Tue, Sep 10, 2024 at 01:52:02AM +0000, David Lin wrote:
> > > > From: Sascha Hauer <s.hauer@pengutronix.de>
> > > > Sent: Tuesday, September 10, 2024 5:05 AM
> > > > To: David Lin <yu-hao.lin@nxp.com>
> > > > Cc: linux-wireless@vger.kernel.org; linux-kernel@vger.kernel.org;
> > > > briannorris@chromium.org; kvalo@kernel.org; francesco@dolcini.it;
> > > > Pete Hsieh <tsung-hsien.hsieh@nxp.com>
> > > > Subject: [EXT] Re: [PATCH v2] wifi: mwifiex: avoid AP and STA
> > > > running on different channel
> > > >
> > > > Caution: This is an external email. Please take care when clicking
> > > > links or opening attachments. When in doubt, report the message
> > > > using the 'Report this email' button
> > > >
> > > >
> > > > On Mon, Sep 02, 2024 at 04:43:11PM +0800, David Lin wrote:
> > > > > Current firmware doesn't support AP and STA running on different
> > > > > channels simultaneously.
> > > > > FW crash would occur in such case.
> > > > > This patch avoids the issue by disabling AP and STA to run on
> > > > > different channels.
> > > > >
> > > > > Signed-off-by: David Lin <yu-hao.lin@nxp.com>
> > > > > ---
> > > > >
> > > > > v2:
> > > > >    - clean up code.
> > > > >
> > > > > ---
> > > > >  .../net/wireless/marvell/mwifiex/cfg80211.c   | 17 ++++---
> > > > >  drivers/net/wireless/marvell/mwifiex/util.c   | 44
> > +++++++++++++++++++
> > > > >  drivers/net/wireless/marvell/mwifiex/util.h   | 13 ++++++
> > > > >  3 files changed, 69 insertions(+), 5 deletions(-)
> > > > >
> > > > > diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
> > > > > b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
> > > > > index 722ead51e912..3dbcab463445 100644
> > > > > --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
> > > > > +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
> > > > > @@ -781,11 +781,9 @@ mwifiex_cfg80211_set_wiphy_params(struct
> > > > > wiphy
> > > > *wiphy, u32 changed)
> > > > >               break;
> > > > >
> > > > >       case MWIFIEX_BSS_ROLE_STA:
> > > > > -             if (priv->media_connected) {
> > > > > -                     mwifiex_dbg(adapter, ERROR,
> > > > > -                                 "cannot change wiphy params
> > > > when connected");
> > > > > -                     return -EINVAL;
> > > > > -             }
> > > > > +             if (priv->media_connected)
> > > > > +                     break;
> > > >
> > > > This hunk seems unrelated to this patch. If this is needed then it
> > > > deserves an extra patch along with an explanation why this is necessary.
> > > >
> > > > Sascha
> > > >
> > >
> > > Without this hunk, AP and STA can't run on the same channel if some
> > > wiphy parameters are setting.
> > 
> > Ok, I now see where you are aiming at. Here's the problematic function:
> > 
> > > static int
> > > mwifiex_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) {
> > >       ...
> > >
> > >       priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
> > >
> > >       switch (priv->bss_role) {
> > >       case MWIFIEX_BSS_ROLE_UAP:
> > >               if (priv->bss_started) {
> > >                       mwifiex_dbg(adapter, ERROR,
> > >                                   "cannot change wiphy params
> > when bss started");
> > >                       return -EINVAL;
> > >               }
> > >
> > >               ...
> > >               mwifiex_send_cmd(priv,
> > HostCmd_CMD_UAP_SYS_CONFIG, ...);
> > >
> > >               break;
> > >       case MWIFIEX_BSS_ROLE_STA:
> > >               if (priv->media_connected) {
> > >                       mwifiex_dbg(adapter, ERROR,
> > >                                   "cannot change wiphy params
> > when connected");
> > >                       return -EINVAL;
> > >               }
> > >
> > >               ...
> > >               mwifiex_send_cmd(priv,
> > HostCmd_CMD_802_11_SNMP_MIB,
> > > ...);
> > >
> > >               break;
> > >       }
> > >
> > >       return 0;
> > > }
> > 
> > This function is for setting wiphy params like rts_threshold and others.
> > 
> > mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY) returns the first priv
> > which by default is in station mode. Now if you start priv0 in station mode,
> > then afterwards start priv1 in AP mode *and* have rts_threshold = xy in your
> > config, then you run into the "cannot change wiphy params when connected"
> > case.
> > 
> > I really wonder if the settings done in this function are per priv or per adapter.
> > Is there one rts_threshold setting in a mwifiex chip or are there multiple (per
> > vif/priv)?
> > 
> > If it's a global setting, then why are we interested in the media_connected
> > state of one specific priv? Shouldn't we check all privs?
> > 
> > If it's a setting per priv, then why do we choose the same priv everytime in this
> > function?
> > 
> > Either way, this function looks fishy and changing it should be done with an
> > explanation, just dropping the error message and returning success is not
> > enough.
> > 
> > Sascha
> > 
> > --
> 
> O.K. I will add comment in patch v3.

Really I hoped that you could clarify a bit how this function works and
answer some of the questions I raised above. That could help us to get
a better driver over time. The same code is in the nxpwifi driver as
well, so it's not only a matter of which driver we decide to maintain
in the future.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2024-09-10  8:31 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-02  8:43 [PATCH v2] wifi: mwifiex: avoid AP and STA running on different channel David Lin
2024-09-02  9:38 ` Sascha Hauer
2024-09-02 10:35   ` [EXT] " David Lin
2024-09-09 20:33     ` Sascha Hauer
2024-09-10  1:55       ` David Lin
2024-09-10  5:55         ` Sascha Hauer
2024-09-10  5:56           ` David Lin
2024-09-10  6:06             ` Sascha Hauer
2024-09-10  6:18               ` David Lin
2024-09-10  7:21                 ` Sascha Hauer
2024-09-10  7:28                   ` David Lin
2024-09-10  8:07                     ` Sascha Hauer
2024-09-10  8:21                       ` David Lin
2024-09-09 21:05 ` Sascha Hauer
2024-09-10  1:52   ` [EXT] " David Lin
2024-09-10  8:00     ` Sascha Hauer
2024-09-10  8:19       ` David Lin
2024-09-10  8:31         ` Sascha Hauer [this message]
2024-09-10  8:35           ` David Lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZuAD5fKyKgHPFN8s@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=briannorris@chromium.org \
    --cc=francesco@dolcini.it \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=tsung-hsien.hsieh@nxp.com \
    --cc=yu-hao.lin@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).