Commit f1871abd authored by Ilan Peer's avatar Ilan Peer Committed by Johannes Berg
Browse files

wifi: mac80211: Add getter functions for vif MLD state



As a preparation to support disabled/dormant links, add the
following function:

- ieee80211_vif_usable_links(): returns the bitmap of the links
  that can be activated. Use this function in all the places that
  the bitmap of the usable links is needed.

- ieee80211_vif_is_mld(): returns true iff the vif is an MLD.
  Use this function in all the places where an indication that the
  connection is a MLD is needed.

Signed-off-by: default avatarIlan Peer <ilan.peer@intel.com>
Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230608163202.86e3351da1fc.If6fe3a339fda2019f13f57ff768ecffb711b710a@changeid


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent bc1be54d
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -1909,6 +1909,27 @@ struct ieee80211_vif {
	u8 drv_priv[] __aligned(sizeof(void *));
};

/**
 * ieee80211_vif_usable_links - Return the usable links for the vif
 * @vif: the vif for which the usable links are requested
 * Return: the usable link bitmap
 */
static inline u16 ieee80211_vif_usable_links(const struct ieee80211_vif *vif)
{
	return vif->valid_links;
}

/**
 * ieee80211_vif_is_mld - Returns true iff the vif is an MLD one
 * @vif: the vif
 * Return: %true if the vif is an MLD, %false otherwise.
 */
static inline bool ieee80211_vif_is_mld(const struct ieee80211_vif *vif)
{
	/* valid_links != 0 indicates this vif is an MLD */
	return vif->valid_links != 0;
}

#define for_each_vif_active_link(vif, link, link_id)				\
	for (link_id = 0; link_id < ARRAY_SIZE((vif)->link_conf); link_id++)	\
		if ((!(vif)->active_links ||					\
+2 −2
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ ieee80211_link_or_deflink(struct ieee80211_sub_if_data *sdata, int link_id,
		 * the return value at all (if it's not a pairwise key),
		 * so in that case (require_valid==false) don't error.
		 */
		if (require_valid && sdata->vif.valid_links)
		if (require_valid && ieee80211_vif_is_mld(&sdata->vif))
			return ERR_PTR(-EINVAL);

		return &sdata->deflink;
@@ -228,7 +228,7 @@ static int ieee80211_change_iface(struct wiphy *wiphy,
			return 0;

		/* FIXME: no support for 4-addr MLO yet */
		if (sdata->vif.valid_links)
		if (ieee80211_vif_is_mld(&sdata->vif))
			return -EOPNOTSUPP;

		sdata->u.mgd.use_4addr = params->use_4addr;
+4 −4
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Portions
 * Copyright (C) 2022 Intel Corporation
 * Copyright (C) 2022 - 2023 Intel Corporation
 */
#ifndef __MAC80211_DEBUG_H
#define __MAC80211_DEBUG_H
@@ -136,7 +136,7 @@ do { \

#define link_info(link, fmt, ...)					\
	do {								\
		if ((link)->sdata->vif.valid_links)			\
		if (ieee80211_vif_is_mld(&(link)->sdata->vif))          \
			_sdata_info((link)->sdata, "[link %d] " fmt,	\
				    (link)->link_id,			\
				    ##__VA_ARGS__);			\
@@ -145,7 +145,7 @@ do { \
	} while (0)
#define link_err(link, fmt, ...)					\
	do {								\
		if ((link)->sdata->vif.valid_links)			\
		if (ieee80211_vif_is_mld(&(link)->sdata->vif))          \
			_sdata_err((link)->sdata, "[link %d] " fmt,	\
				   (link)->link_id,			\
				   ##__VA_ARGS__);			\
@@ -154,7 +154,7 @@ do { \
	} while (0)
#define link_dbg(link, fmt, ...)					\
	do {								\
		if ((link)->sdata->vif.valid_links)			\
		if (ieee80211_vif_is_mld(&(link)->sdata->vif))          \
			_sdata_dbg(1, (link)->sdata, "[link %d] " fmt,	\
				   (link)->link_id,			\
				   ##__VA_ARGS__);			\
+1 −1
Original line number Diff line number Diff line
@@ -1614,7 +1614,7 @@ ieee80211_get_sband(struct ieee80211_sub_if_data *sdata)
	struct ieee80211_chanctx_conf *chanctx_conf;
	enum nl80211_band band;

	WARN_ON(sdata->vif.valid_links);
	WARN_ON(ieee80211_vif_is_mld(&sdata->vif));

	rcu_read_lock();
	chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
+2 −2
Original line number Diff line number Diff line
@@ -521,7 +521,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do
	cancel_work_sync(&sdata->recalc_smps);

	sdata_lock(sdata);
	WARN(sdata->vif.valid_links,
	WARN(ieee80211_vif_is_mld(&sdata->vif),
	     "destroying interface with valid links 0x%04x\n",
	     sdata->vif.valid_links);

@@ -1815,7 +1815,7 @@ static int ieee80211_runtime_change_iftype(struct ieee80211_sub_if_data *sdata,
		return -EBUSY;

	/* for now, don't support changing while links exist */
	if (sdata->vif.valid_links)
	if (ieee80211_vif_is_mld(&sdata->vif))
		return -EBUSY;

	switch (sdata->vif.type) {
Loading