public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Johnson <quic_jjohnson@quicinc.com>
To: Rameshkumar Sundaram <quic_ramess@quicinc.com>,
	<ath12k@lists.infradead.org>
Cc: <linux-wireless@vger.kernel.org>, Sriram R <quic_srirrama@quicinc.com>
Subject: Re: [PATCH v4 07/12] wifi: ath12k: Cache vdev configs before vdev create
Date: Tue, 12 Mar 2024 16:01:04 -0700	[thread overview]
Message-ID: <0beccca3-ffca-4eb1-b152-e31e9f3b3e21@quicinc.com> (raw)
In-Reply-To: <20240312135557.1778379-8-quic_ramess@quicinc.com>

On 3/12/2024 6:55 AM, Rameshkumar Sundaram wrote:
> From: Sriram R <quic_srirrama@quicinc.com>
> 
> Since the vdev create for a corresponding vif is deferred
> until a channel is assigned, cache the information which
> are received through mac80211 ops between add_interface()
> and assign_vif_chanctx() and set them once the vdev is
> created on one of the ath12k radios as the channel gets
> assigned via assign_vif_chanctx().
> 
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
> 
> Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
> Signed-off-by: Rameshkumar Sundaram <quic_ramess@quicinc.com>
> ---
>  drivers/net/wireless/ath/ath12k/core.h |  19 ++++
>  drivers/net/wireless/ath/ath12k/mac.c  | 116 +++++++++++++++++++------
>  2 files changed, 107 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
> index 70daec38d486..fe151aa90687 100644
> --- a/drivers/net/wireless/ath/ath12k/core.h
> +++ b/drivers/net/wireless/ath/ath12k/core.h
> @@ -214,6 +214,24 @@ enum ath12k_monitor_flags {
>  	ATH12K_FLAG_MONITOR_ENABLED,
>  };
>  
> +struct ath12k_tx_conf {
> +	bool changed;
> +	u16 ac;
> +	struct ieee80211_tx_queue_params tx_queue_params;
> +};
> +
> +struct ath12k_key_conf {
> +	bool changed;
> +	enum set_key_cmd cmd;
> +	struct ieee80211_key_conf *key;
> +};
> +
> +struct ath12k_vif_cache {
> +	struct ath12k_tx_conf tx_conf;
> +	struct ath12k_key_conf key_conf;
> +	u32 bss_conf_changed;
> +};
> +
>  struct ath12k_vif {
>  	u32 vdev_id;
>  	enum wmi_vdev_type vdev_type;
> @@ -268,6 +286,7 @@ struct ath12k_vif {
>  	u8 vdev_stats_id;
>  	u32 punct_bitmap;
>  	bool ps;
> +	struct ath12k_vif_cache cache;

is there a reason this isn't a *cache?
this allocation is only needed for the time between when a vdev is created and
when a channel is assigned, so why not have a dynamic allocation that is only
around for that time? otherwise for every vdev you waste this memory for the
lifetime of the vdev.

>  };
>  
>  struct ath12k_vif_iter {
> diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
> index 6d2176b0a556..fab92f08fdb7 100644
> --- a/drivers/net/wireless/ath/ath12k/mac.c
> +++ b/drivers/net/wireless/ath/ath12k/mac.c
> @@ -3021,12 +3021,14 @@ static void ath12k_mac_op_bss_info_changed(struct ieee80211_hw *hw,
>  
>  	ar = ath12k_get_ar_by_vif(hw, vif);
>  
> -	/* TODO if the vdev is not created on a certain radio,
> +	/* if the vdev is not created on a certain radio,
>  	 * cache the info to be updated later on vdev creation
>  	 */
>  
> -	if (!ar)
> +	if (!ar) {
> +		arvif->cache.bss_conf_changed |= changed;

why don't you need to save the actual *info as well?

>  		return;
> +	}
>  
>  	mutex_lock(&ar->conf_mutex);
>  
> @@ -3517,12 +3519,11 @@ static int ath12k_clear_peer_keys(struct ath12k_vif *arvif,
>  	return first_errno;
>  }
>  
> -static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
> -				 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
> -				 struct ieee80211_key_conf *key)
> +static int ath12k_mac_set_key(struct ath12k *ar, enum set_key_cmd cmd,
> +			      struct ieee80211_vif *vif, struct ieee80211_sta *sta,
> +			      struct ieee80211_key_conf *key)
>  {
> -	struct ath12k *ar;
> -	struct ath12k_base *ab;
> +	struct ath12k_base *ab = ar->ab;
>  	struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
>  	struct ath12k_peer *peer;
>  	struct ath12k_sta *arsta;
> @@ -3530,28 +3531,11 @@ static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
>  	int ret = 0;
>  	u32 flags = 0;
>  
> -	/* BIP needs to be done in software */
> -	if (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC ||
> -	    key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 ||
> -	    key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256 ||
> -	    key->cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256)
> -		return 1;
> -
> -	ar = ath12k_get_ar_by_vif(hw, vif);
> -	if (!ar) {
> -		WARN_ON_ONCE(1);
> -		return -EINVAL;
> -	}
> -	ab = ar->ab;
> +	lockdep_assert_held(&ar->conf_mutex);
>  
> -	if (test_bit(ATH12K_FLAG_HW_CRYPTO_DISABLED, &ar->ab->dev_flags))
> +	if (test_bit(ATH12K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags))
>  		return 1;
>  
> -	if (key->keyidx > WMI_MAX_KEY_INDEX)
> -		return -ENOSPC;
> -
> -	mutex_lock(&ar->conf_mutex);
> -
>  	if (sta)
>  		peer_addr = sta->addr;
>  	else if (arvif->vdev_type == WMI_VDEV_TYPE_STA)
> @@ -3643,6 +3627,43 @@ static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
>  	spin_unlock_bh(&ab->base_lock);
>  
>  exit:
> +	return ret;
> +}
> +
> +
> +static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
> +				 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
> +				 struct ieee80211_key_conf *key)
> +{
> +	struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
> +	struct ath12k *ar;
> +	int ret;
> +
> +	/* BIP needs to be done in software */
> +	if (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC ||
> +	    key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 ||
> +	    key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256 ||
> +	    key->cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256)
> +		return 1;
> +
> +	if (key->keyidx > WMI_MAX_KEY_INDEX)
> +		return -ENOSPC;
> +
> +	ar = ath12k_get_ar_by_vif(hw, vif);
> +	if (!ar) {
> +		/* ar is expected to be valid when sta ptr is available */
> +		if (sta) {
> +			WARN_ON_ONCE(1);
> +			return -EINVAL;
> +		}
> +		arvif->cache.key_conf.cmd = cmd;
> +		arvif->cache.key_conf.key = key;
> +		arvif->cache.key_conf.changed = true;
> +		return 0;
> +	}
> +
> +	mutex_lock(&ar->conf_mutex);
> +	ret = ath12k_mac_set_key(ar, cmd, vif, sta, key);
>  	mutex_unlock(&ar->conf_mutex);
>  	return ret;
>  }
> @@ -4477,7 +4498,10 @@ static int ath12k_mac_op_conf_tx(struct ieee80211_hw *hw,
>  
>  	ar = ath12k_get_ar_by_vif(hw, vif);
>  	if (!ar) {
> -		/* TODO cache the info and apply after vdev is created */
> +		/* cache the info and apply after vdev is created */
> +		arvif->cache.tx_conf.changed = true;
> +		arvif->cache.tx_conf.ac = ac;
> +		arvif->cache.tx_conf.tx_queue_params = *params;
>  		return -EINVAL;
>  	}
>  
> @@ -6121,6 +6145,41 @@ static int ath12k_mac_vdev_create(struct ath12k *ar, struct ieee80211_vif *vif)
>  	return ret;
>  }
>  
> +static void ath12k_mac_vif_cache_flush(struct ath12k *ar,  struct ieee80211_vif *vif)
> +{
> +	struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
> +	struct ath12k_base *ab = ar->ab;
> +	int ret;
> +
> +	lockdep_assert_held(&ar->conf_mutex);
> +
> +	if (arvif->cache.tx_conf.changed) {
> +		ret = ath12k_mac_conf_tx(arvif, 0, arvif->cache.tx_conf.ac,
> +					 &arvif->cache.tx_conf.tx_queue_params);
> +		if (ret)
> +			ath12k_warn(ab,
> +				    "unable to apply tx config parameters to vdev %d\n",
> +				    ret);
> +	}
> +
> +	if (arvif->cache.bss_conf_changed)
> +		ath12k_mac_bss_info_changed(ar, arvif, &vif->bss_conf,
> +					    arvif->cache.bss_conf_changed);
> +
> +	if (arvif->cache.key_conf.changed) {
> +		ret = ath12k_mac_set_key(ar, arvif->cache.key_conf.cmd,
> +					 vif, NULL,
> +					 arvif->cache.key_conf.key);
> +		if (ret) {
> +			WARN_ON_ONCE(1);
> +			ath12k_warn(ab, "unable to apply set key param to vdev %d ret %d\n",
> +				    arvif->vdev_id, ret);
> +		}
> +	}
> +
> +	memset(&arvif->cache, 0, sizeof(struct ath12k_vif_cache));

sizeof(arvif->cache)

> +}
> +
>  static struct ath12k *ath12k_mac_assign_vif_to_vdev(struct ieee80211_hw *hw,
>  						    struct ieee80211_vif *vif,
>  						    struct ieee80211_chanctx_conf *ctx)
> @@ -6203,10 +6262,11 @@ static struct ath12k *ath12k_mac_assign_vif_to_vdev(struct ieee80211_hw *hw,
>  		goto unlock;
>  	}
>  
> -	/* TODO If the vdev is created during channel assign and not during
> +	/* If the vdev is created during channel assign and not during
>  	 * add_interface(), Apply any parameters for the vdev which were received
>  	 * after add_interface, corresponding to this vif.
>  	 */
> +	ath12k_mac_vif_cache_flush(ar, vif);
>  unlock:
>  	mutex_unlock(&ar->conf_mutex);
>  out:


  reply	other threads:[~2024-03-12 23:01 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12 13:55 [PATCH v4 00/12] wifi: ath12k: Add single wiphy support Rameshkumar Sundaram
2024-03-12 13:55 ` [PATCH v4 01/12] wifi: ath12k: add multiple radio support in a single MAC HW un/register Rameshkumar Sundaram
2024-03-12 21:53   ` Jeff Johnson
2024-03-13 12:57     ` Rameshkumar Sundaram
2024-03-13 15:06       ` Jeff Johnson
2024-03-13 16:48         ` Kalle Valo
2024-03-13 16:58           ` Kalle Valo
2024-03-13 18:04             ` Jeff Johnson
2024-03-13 19:56               ` Jonas Gorski
2024-03-14 19:38                 ` Rameshkumar Sundaram
2024-03-18 18:36                   ` Kalle Valo
2024-03-19 15:51                     ` Rameshkumar Sundaram
2024-03-12 13:55 ` [PATCH v4 02/12] wifi: ath12k: Modify add and remove chanctx ops for single wiphy support Rameshkumar Sundaram
2024-03-12 21:58   ` Jeff Johnson
2024-03-12 13:55 ` [PATCH v4 03/12] wifi: ath12k: modify ath12k mac start/stop ops for single wiphy Rameshkumar Sundaram
2024-03-12 22:13   ` Jeff Johnson
2024-03-13 14:29     ` Rameshkumar Sundaram
2024-03-12 13:55 ` [PATCH v4 04/12] wifi: ath12k: vdev statemachine changes " Rameshkumar Sundaram
2024-03-12 22:25   ` Jeff Johnson
2024-03-13 14:36     ` Rameshkumar Sundaram
2024-03-14 10:17   ` kernel test robot
2024-03-12 13:55 ` [PATCH v4 05/12] wifi: ath12k: scan " Rameshkumar Sundaram
2024-03-12 22:35   ` Jeff Johnson
2024-03-19 15:58     ` Rameshkumar Sundaram
2024-03-12 13:55 ` [PATCH v4 06/12] wifi: ath12k: fetch correct radio based on vdev status Rameshkumar Sundaram
2024-03-12 22:48   ` Jeff Johnson
2024-03-12 13:55 ` [PATCH v4 07/12] wifi: ath12k: Cache vdev configs before vdev create Rameshkumar Sundaram
2024-03-12 23:01   ` Jeff Johnson [this message]
2024-03-19 16:12     ` Rameshkumar Sundaram
2024-03-12 13:55 ` [PATCH v4 08/12] wifi: ath12k: Add additional checks for vif and sta iterators Rameshkumar Sundaram
2024-03-12 23:06   ` Jeff Johnson
2024-03-12 13:55 ` [PATCH v4 09/12] wifi: ath12k: modify regulatory support for single wiphy architecture Rameshkumar Sundaram
2024-03-12 23:13   ` Jeff Johnson
2024-03-12 13:55 ` [PATCH v4 10/12] wifi: ath12k: Modify set and get antenna mac ops for single wiphy Rameshkumar Sundaram
2024-03-12 23:18   ` Jeff Johnson
2024-03-12 13:55 ` [PATCH v4 11/12] wifi: ath12k: Modify rts threshold mac op " Rameshkumar Sundaram
2024-03-12 23:21   ` Jeff Johnson
2024-03-12 13:55 ` [PATCH v4 12/12] wifi: ath12k: support get_survey " Rameshkumar Sundaram
2024-03-12 23:25   ` Jeff Johnson
2024-03-19 16:22     ` Rameshkumar Sundaram
2024-03-12 20:59 ` [PATCH v4 00/12] wifi: ath12k: Add single wiphy support Jeff Johnson

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=0beccca3-ffca-4eb1-b152-e31e9f3b3e21@quicinc.com \
    --to=quic_jjohnson@quicinc.com \
    --cc=ath12k@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=quic_ramess@quicinc.com \
    --cc=quic_srirrama@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