public inbox for ath12k@lists.infradead.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Karthikeyan Periyasamy <quic_periyasa@quicinc.com>,
	 ath12k@lists.infradead.org
Cc: linux-wireless@vger.kernel.org,
	Vasanthakumar Thiagarajan <quic_vthiagar@quicinc.com>
Subject: Re: [PATCH 09/13] wifi: cfg80211: Add multi-hardware iface combination support
Date: Thu, 28 Mar 2024 15:16:26 +0100	[thread overview]
Message-ID: <a24b7d967dbe31ef613fae8c331f4ff718482c93.camel@sipsolutions.net> (raw)
In-Reply-To: <20240328072916.1164195-10-quic_periyasa@quicinc.com>

On Thu, 2024-03-28 at 12:59 +0530, Karthikeyan Periyasamy wrote:
> 
>   * @new_beacon_int: set this to the beacon interval of a new interface
>   *	that's not operating yet, if such is to be checked as part of
>   *	the verification
> + * @chandef: Channel definition for which the interface combination is to be
> + *	checked, when checking during interface preparation on a new channel,
> + *	for example. This will be used when the driver advertises underlying
> + *	hw specific interface combination in a multi physical hardware device.
> + *	This will be NULL when the interface combination check is not due to
> + *	channel or the interface combination does not include per-hw
> + *	advertisement.

This is input, so "will be" doesn't make much sense, more like "must
be"?

But I'm confused as to how that works with num_different_channels being
here too?

This function was, as far as I can tell, always checking the _full_
state. Now you're changing that, and I'm neither sure why, nor does it
seem well documented.

> + * @n_per_hw: number of Per-HW interface combinations.
> + * @per_hw: @n_per_hw of hw specific interface combinations. Per-hw channel
> + *	list index as advertised in wiphy @hw_chans is used as index
> + *	in @per_hw to maintain the interface combination of the corresponding
> + *	hw.

What?

If I'm reading that correctly, which is all but guaranteed, doesn't that
actually mean you don't need n_per_hw at all, since it necessarily equal
to n_hw_chans?

> +/**
> + * cfg80211_per_hw_iface_comb_advertised - if per-hw iface combination supported
> + *
> + * @wiphy: the wiphy
> + *
> + * This function is used to check underlying per-hw interface combination is
> + * advertised by the driver.
> + */
> +bool cfg80211_per_hw_iface_comb_advertised(struct wiphy *wiphy);

Is that even worth an export rather than being inline? Is it even needed
outside of cfg80211 itself?

Also for cfg80211_get_hw_idx_by_chan(), is it really needed?

I'm also wondering if we really should use the "hw_idx" everywhere.
Maybe that'd be more useful as a pointer to struct
ieee80211_chans_per_hw in most places (other than nl80211, obviously)?

The index always feels pretty fragile, a pointer at least gives us type-
checking?

Even in the interface combination advertising, perhaps, though not sure
how that'd work for the drivers.

> +static const struct ieee80211_iface_per_hw *
> +cfg80211_get_hw_iface_comb_by_idx(struct wiphy *wiphy,
> +				  const struct ieee80211_iface_combination *c,
> +				  int idx)
> +{
> +	int i;
> +
> +	for (i = 0; i < c->n_hw_list; i++)
> +		if (c->iface_hw_list[i].hw_chans_idx == idx)
> +			break;
> +
> +	if (i == c->n_hw_list)
> +		return NULL;
> +
> +	return &c->iface_hw_list[i];
> +}

???

Hint: it's perfectly legal to return directly from a loop.

> +static int
> +cfg80211_validate_iface_comb_per_hw_limits(struct wiphy *wiphy,
> +					   struct iface_combination_params *params,
> +					   const struct ieee80211_iface_combination *c,
> +					   u16 *num_ifaces, u32 *all_iftypes)
> +{
> +	struct ieee80211_iface_limit *limits;
> +	const struct iface_comb_per_hw_params *per_hw;
> +	const struct ieee80211_iface_per_hw *per_hw_comb;
> +	int i, ret = 0;

The = 0 doesn't seem needed.

> +		ret = cfg80211_validate_iface_limits(wiphy,
> +						     per_hw->iftype_num,
> +						     limits,
> +						     per_hw_comb->n_limits,
> +						     all_iftypes);
> +
> +		kfree(limits);
> +
> +		if (ret)
> +			goto out;
> +	}
> +
> +out:
> +	return ret;

That 'out' label is pointless.

> +static void cfg80211_put_iface_comb_iftypes(u16 *num_ifaces)
> +{
> +	kfree(num_ifaces);
> +}

Not sure I see value in that indirection?

> +static u16*

missing space

> +cfg80211_get_iface_comb_iftypes(struct wiphy *wiphy,
> +				struct iface_combination_params *params,
> +				u32 *used_iftypes)
> +{
> +	const struct iface_comb_per_hw_params *per_hw;
> +	u16 *num_ifaces;
> +	int i;
> +	u8 num_hw;
> +
> +	num_hw = params->n_per_hw ? params->n_per_hw : 1;

I think we're allowed to use the "?:" shortcut.

> +	num_ifaces = kcalloc(num_hw, sizeof(*num_ifaces), GFP_KERNEL);
> +	if (!num_ifaces)
> +		return NULL;

But ... maybe we should just cap num_hw to a reasonable limit (4? 5?)
and use a static array in the caller instead of allocating here.

> +	is_per_hw = cfg80211_per_hw_iface_comb_advertised(wiphy);

Maybe call that "have_per_hw_combinations" or so? Or "check_per_hw"
even, "is" seems not clear - "what is?"

> +	/* check per HW validation */
> +	if (params->n_per_hw) {
> +		if (!is_per_hw)
> +			return -EINVAL;
> +
> +		if (params->n_per_hw > wiphy->num_hw)
> +			return -EINVAL;
> +	}
> +
> +	if (is_per_hw && params->chandef &&
> +	    cfg80211_chandef_valid(params->chandef))
> +		hw_chan_idx = cfg80211_get_hw_idx_by_chan(wiphy,
> +							  params->chandef->chan);
> +
> +	num_ifaces = cfg80211_get_iface_comb_iftypes(wiphy,
> +						     params,
> +						     &used_iftypes);
> +	if (!num_ifaces)
> +		return -ENOMEM;

But still like I said above, all this code seems really odd to me now,
it's checking *either* the per-hw and then only for a single HW, *or*
the global, but ... seems it should do full checks for both, if needed?

johannes


  reply	other threads:[~2024-03-28 14:16 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28  7:29 [PATCH 00/13] wifi: Add multi physical hardware iface combination support Karthikeyan Periyasamy
2024-03-28  7:29 ` [PATCH 01/13] wifi: cfg80211: Add provision to advertise multiple radio in one wiphy Karthikeyan Periyasamy
2024-03-28  7:46   ` Johannes Berg
2024-03-29 14:11     ` Vasanthakumar Thiagarajan
2024-03-29 14:30       ` Johannes Berg
2024-03-29 14:47         ` Ben Greear
2024-04-10  7:56           ` Johannes Berg
2024-04-10 14:37             ` Ben Greear
2024-04-10 15:42               ` Johannes Berg
2024-04-10 16:23                 ` Ben Greear
2024-04-10 16:43                   ` Jeff Johnson
2024-04-10 18:08                     ` Maxime Bizon
2024-04-11 16:26                       ` Vasanthakumar Thiagarajan
2024-04-11 16:39                         ` Maxime Bizon
2024-04-12  3:50                           ` Vasanthakumar Thiagarajan
2024-04-12  7:38                             ` Nicolas Escande
2024-04-12  8:01                               ` Vasanthakumar Thiagarajan
2024-04-12 12:00                                 ` James Dutton
2024-04-12 14:39                                   ` Vasanthakumar Thiagarajan
2024-04-10 18:01                   ` Maxime Bizon
2024-04-10 21:03                 ` Ben Greear
2024-04-12  4:11                   ` Vasanthakumar Thiagarajan
2024-04-12 14:08                     ` Ben Greear
2024-04-12 14:31                       ` Vasanthakumar Thiagarajan
2024-04-12 15:58                         ` Ben Greear
2024-04-13 15:40                           ` Ben Greear
2024-04-14 16:02                             ` Vasanthakumar Thiagarajan
2024-04-15 13:59                               ` Ben Greear
2024-04-14 15:52                           ` Vasanthakumar Thiagarajan
2024-04-15 13:53                             ` Ben Greear
2024-04-01  4:19     ` Karthikeyan Periyasamy
2024-04-10  9:08     ` Karthikeyan Periyasamy
2024-04-10  9:09       ` Johannes Berg
2024-04-10  9:15         ` Karthikeyan Periyasamy
2024-03-28  7:29 ` [PATCH 02/13] wifi: nl80211: send underlying multi-hardware channel capabilities to user space Karthikeyan Periyasamy
2024-03-28  7:49   ` Johannes Berg
2024-03-28 10:18     ` Karthikeyan Periyasamy
2024-03-28 12:01       ` Johannes Berg
2024-03-28 15:10         ` Karthikeyan Periyasamy
2024-03-28 16:09           ` Johannes Berg
2024-03-28 16:14             ` Jeff Johnson
2024-03-28 16:17               ` Jeff Johnson
2024-03-28 16:17               ` Johannes Berg
2024-03-28 16:18                 ` Johannes Berg
2024-03-28 18:49         ` Jakub Kicinski
2024-03-28 18:53           ` Johannes Berg
2024-03-28 18:57             ` Jakub Kicinski
2024-03-28 19:32               ` Johannes Berg
2024-03-29 14:21         ` Vasanthakumar Thiagarajan
2024-04-10  7:59           ` Johannes Berg
2024-04-10 16:52             ` Jeff Johnson
2024-03-28  7:29 ` [PATCH 03/13] wifi: cfg80211: Refactor the interface combination limit check Karthikeyan Periyasamy
2024-03-28  7:29 ` [PATCH 04/13] wifi: cfg80211/mac80211: extend iface comb advertisement for multi-hardware dev Karthikeyan Periyasamy
2024-03-28 13:22   ` Johannes Berg
2024-04-01  9:56     ` Karthikeyan Periyasamy
2024-03-28  7:29 ` [PATCH 05/13] wifi: nl80211: Refactor the interface combination limit check Karthikeyan Periyasamy
2024-03-28  7:29 ` [PATCH 06/13] wifi: nl80211: send iface combination to user space in multi-hardware wiphy Karthikeyan Periyasamy
2024-03-28 13:33   ` Johannes Berg
2024-03-28 16:19     ` Jeff Johnson
2024-03-29 14:34     ` Vasanthakumar Thiagarajan
2024-04-10  4:10       ` Karthikeyan Periyasamy
2024-04-10  6:59         ` Johannes Berg
2024-04-12  5:27       ` Karthikeyan Periyasamy
2024-04-12  5:45         ` Karthikeyan Periyasamy
2024-04-15 14:27         ` Johannes Berg
2024-04-15 15:57           ` Karthikeyan Periyasamy
2024-03-28  7:29 ` [PATCH 07/13] wifi: cfg80211/mac80211: Refactor iface comb iterate callback for multi-hardware dev Karthikeyan Periyasamy
2024-03-28 13:36   ` Johannes Berg
2024-03-28  7:29 ` [PATCH 08/13] wifi: cfg80211: Refactor the iface combination iteration helper function Karthikeyan Periyasamy
2024-03-28 13:43   ` Johannes Berg
2024-04-02 16:35     ` Karthikeyan Periyasamy
2024-03-28  7:29 ` [PATCH 09/13] wifi: cfg80211: Add multi-hardware iface combination support Karthikeyan Periyasamy
2024-03-28 14:16   ` Johannes Berg [this message]
2024-04-03  9:58     ` Karthikeyan Periyasamy
2024-03-28  7:29 ` [PATCH 10/13] wifi: mac80211: expose channel context helper function Karthikeyan Periyasamy
2024-03-28  7:29 ` [PATCH 11/13] wifi: mac80211: Add multi-hardware support in the iface comb helper Karthikeyan Periyasamy
2024-03-28 14:41   ` Johannes Berg
2024-03-28 16:39     ` Jeff Johnson
2024-04-23 16:01     ` Karthikeyan Periyasamy
2024-03-28  7:29 ` [PATCH 12/13] wifi: ath12k: Introduce iface combination cleanup helper Karthikeyan Periyasamy
2024-03-28  7:29 ` [PATCH 13/13] wifi: ath12k: Advertise multi hardware iface combination Karthikeyan Periyasamy
2024-03-28 23:42   ` kernel test robot
2024-05-22 14:55 ` [PATCH 00/13] wifi: Add multi physical hardware iface combination support Felix Fietkau
2024-05-23 16:41   ` Johannes Berg
2024-05-27  6:58     ` Aditya Kumar Singh

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=a24b7d967dbe31ef613fae8c331f4ff718482c93.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=ath12k@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=quic_periyasa@quicinc.com \
    --cc=quic_vthiagar@quicinc.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