linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: "Ganapathi Bhat" <ganapathi.bhat@nxp.com>,
	"Amitkumar Karwar" <amitkarwar@gmail.com>,
	"Xinming Hu" <huxinming820@gmail.com>,
	linux-wireless@vger.kernel.org,
	"Marek Behún" <marek.behun@nic.cz>
Subject: mwifiex: Initialization of FW and net interface
Date: Fri, 12 Jun 2020 12:35:01 +0200	[thread overview]
Message-ID: <20200612103501.vhwo3skvzt2243gz@pali> (raw)

Hello!

I was looking at mwifiex code which initialize card firmware and linux
network interface and I think that there are some issues with this code
path.

There is a function mwifiex_sta_init_cmd() which basically doing two
different things:

 * initial card firmware initialization
 * configuration of interface parameters via card firmware

That function has following definition:

int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init);

'first_sta' and 'init' is FALSE when doing just configuration of
interface parameters (by cfg80211 callbacks).

'init' is TRUE when doing initial card firmware initialization and it is
called when mwifiex driver is doing setup of card. But this function is
called with 'init' set to TRUE multiple times when card driver was
configured to create multiple linux network interfaces. In this case
'first_sta' is TRUE only for the first call of this function.

And now the first suspicious thing is: Why mwifiex driver calls that
initial card firmware initialization multiple times when network
interfaces are created during driver setup, and not when they are
created later by "iw phy phyX interface add ..."?

Next, looking at code of that function mwifiex_sta_init_cmd() it looks
like that all commands send to firmware are "global" and affects all
existing mwifiex network interfaces. Why then it is needed to call this
function when creating a new interface? (E.g. second bssid for AP mode).

Also if it really affects all existing interfaces, it means that
creating a new interface changes configured cfg80211 parameters of all
existing interfaces to some default values.

This also affects power save settings which I described in previous email:
https://lore.kernel.org/linux-wireless/20200609111544.v7u5ort3yk4s7coy@pali/

And the last and the most suspicious thing in that mwifiex_sta_init_cmd
function is that some AP related code is executed only during initial
card firmware initialization and only if initial interface is AP mode
('init' = TRUE, 'first_sta' = TRUE, mode = 'AP').

Seems that driver behaves differently if interfaces are created by
standard 'iw phy phyX interface add ..." command (via cfg80211 layer)
and differently if interfaces are created automatically during driver
setup function.

Are there any reasons for these differences? And what to do with the
fact that most firmware commands which affects all interfaces and not
just one which is initializing?

These issues which I described makes it hard for me to understand what
is driver really doing and what should be correct behavior.

By the way, do you have documentation for firmware commands?

             reply	other threads:[~2020-06-12 10:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-12 10:35 Pali Rohár [this message]
2021-07-17 13:47 ` mwifiex: Initialization of FW and net interface Pali Rohár

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=20200612103501.vhwo3skvzt2243gz@pali \
    --to=pali@kernel.org \
    --cc=amitkarwar@gmail.com \
    --cc=ganapathi.bhat@nxp.com \
    --cc=huxinming820@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=marek.behun@nic.cz \
    /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).