diff mbox series

[7/8] wifi: ath12k: add helper to find multi-link station

Message ID 20241023133004.2253830-8-kvalo@kernel.org (mailing list archive)
State Changes Requested
Delegated to: Jeff Johnson
Headers show
Series wifi: ath12k: MLO support part 2 | expand

Commit Message

Kalle Valo Oct. 23, 2024, 1:30 p.m. UTC
From: Sriram R <quic_srirrama@quicinc.com>

Multi-link stations are identified in driver using the multi-link
peer id. Add a helper to find multi-link station using the ML
peer id.

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: Harshitha Prem <quic_hprem@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
---
 drivers/net/wireless/ath/ath12k/dp.h   |  2 ++
 drivers/net/wireless/ath/ath12k/peer.c | 17 +++++++++++++++++
 drivers/net/wireless/ath/ath12k/peer.h |  2 ++
 3 files changed, 21 insertions(+)

Comments

Jeff Johnson Oct. 23, 2024, 4:01 p.m. UTC | #1
On 10/23/2024 6:30 AM, Kalle Valo wrote:
> From: Sriram R <quic_srirrama@quicinc.com>
> 
> Multi-link stations are identified in driver using the multi-link
> peer id. Add a helper to find multi-link station using the ML
> peer id.
> 
> 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: Harshitha Prem <quic_hprem@quicinc.com>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
> ---
>  drivers/net/wireless/ath/ath12k/dp.h   |  2 ++
>  drivers/net/wireless/ath/ath12k/peer.c | 17 +++++++++++++++++
>  drivers/net/wireless/ath/ath12k/peer.h |  2 ++
>  3 files changed, 21 insertions(+)
> 
> diff --git a/drivers/net/wireless/ath/ath12k/dp.h b/drivers/net/wireless/ath/ath12k/dp.h
> index 2e05fc19410e..66b60f772efb 100644
> --- a/drivers/net/wireless/ath/ath12k/dp.h
> +++ b/drivers/net/wireless/ath/ath12k/dp.h
> @@ -1796,6 +1796,8 @@ static inline void ath12k_dp_get_mac_addr(u32 addr_l32, u16 addr_h16, u8 *addr)
>  	memcpy(addr + 4, &addr_h16, ETH_ALEN - 4);
>  }
>  
> +#define ATH12K_ML_PEER_ID_VALID         BIT(13)
> +

this seems to be randomly placed without any context

>  int ath12k_dp_service_srng(struct ath12k_base *ab,
>  			   struct ath12k_ext_irq_grp *irq_grp,
>  			   int budget);
> diff --git a/drivers/net/wireless/ath/ath12k/peer.c b/drivers/net/wireless/ath/ath12k/peer.c
> index 39b371c7433c..c7eb60723d83 100644
> --- a/drivers/net/wireless/ath/ath12k/peer.c
> +++ b/drivers/net/wireless/ath/ath12k/peer.c
> @@ -80,6 +80,20 @@ struct ath12k_peer *ath12k_peer_find_by_addr(struct ath12k_base *ab,
>  	return NULL;
>  }
>  
> +static struct ath12k_peer *ath12k_peer_find_by_ml_id(struct ath12k_base *ab,
> +						     int ml_peer_id)
> +{
> +	struct ath12k_peer *peer;
> +
> +	lockdep_assert_held(&ab->base_lock);
> +
> +	list_for_each_entry(peer, &ab->peers, list)
> +		if (ml_peer_id == peer->ml_peer_id)
> +			return peer;
> +
> +	return NULL;
> +}
> +
>  struct ath12k_peer *ath12k_peer_find_by_id(struct ath12k_base *ab,
>  					   int peer_id)
>  {
> @@ -87,6 +101,9 @@ struct ath12k_peer *ath12k_peer_find_by_id(struct ath12k_base *ab,
>  
>  	lockdep_assert_held(&ab->base_lock);
>  
> +	if (peer_id & ATH12K_ML_PEER_ID_VALID)

where is code that sets the bit?

does other code elsewhere need to mask this bit off to have the "true" peer_id?

the commit text for this patch seems to need a lot more description

> +		return ath12k_peer_find_by_ml_id(ab, peer_id);
> +
>  	list_for_each_entry(peer, &ab->peers, list)
>  		if (peer_id == peer->peer_id)
>  			return peer;
> diff --git a/drivers/net/wireless/ath/ath12k/peer.h b/drivers/net/wireless/ath/ath12k/peer.h
> index b91bb2106b76..5b718fc5c795 100644
> --- a/drivers/net/wireless/ath/ath12k/peer.h
> +++ b/drivers/net/wireless/ath/ath12k/peer.h
> @@ -47,6 +47,8 @@ struct ath12k_peer {
>  
>  	/* protected by ab->data_lock */
>  	bool dp_setup_done;
> +
> +	u16 ml_peer_id;
>  };
>  
>  struct ath12k_ml_peer {
Kalle Valo Oct. 29, 2024, 4:02 p.m. UTC | #2
Jeff Johnson <quic_jjohnson@quicinc.com> writes:

> On 10/23/2024 6:30 AM, Kalle Valo wrote:
>
>> --- a/drivers/net/wireless/ath/ath12k/dp.h
>> +++ b/drivers/net/wireless/ath/ath12k/dp.h
>> @@ -1796,6 +1796,8 @@ static inline void ath12k_dp_get_mac_addr(u32 addr_l32, u16 addr_h16, u8 *addr)
>>  	memcpy(addr + 4, &addr_h16, ETH_ALEN - 4);
>>  }
>>  
>> +#define ATH12K_ML_PEER_ID_VALID         BIT(13)
>> +
>
> this seems to be randomly placed without any context

Yeah, it is. I'll try to find a better place for it.

>> @@ -87,6 +101,9 @@ struct ath12k_peer *ath12k_peer_find_by_id(struct ath12k_base *ab,
>>  
>>  	lockdep_assert_held(&ab->base_lock);
>>  
>> +	if (peer_id & ATH12K_ML_PEER_ID_VALID)
>
> where is code that sets the bit?

That will come later in patch 'wifi: ath12k: Add support for HTT MLO peer map and unmap event'.

> does other code elsewhere need to mask this bit off to have the "true" peer_id?

I'll investigate this.

> the commit text for this patch seems to need a lot more description

Will fix.
Kalle Valo Nov. 1, 2024, 2:33 p.m. UTC | #3
Jeff Johnson <quic_jjohnson@quicinc.com> writes:

>> --- a/drivers/net/wireless/ath/ath12k/peer.c
>> +++ b/drivers/net/wireless/ath/ath12k/peer.c
>> @@ -80,6 +80,20 @@ struct ath12k_peer *ath12k_peer_find_by_addr(struct ath12k_base *ab,
>>  	return NULL;
>>  }
>>  
>> +static struct ath12k_peer *ath12k_peer_find_by_ml_id(struct ath12k_base *ab,
>> +						     int ml_peer_id)
>> +{
>> +	struct ath12k_peer *peer;
>> +
>> +	lockdep_assert_held(&ab->base_lock);
>> +
>> +	list_for_each_entry(peer, &ab->peers, list)
>> +		if (ml_peer_id == peer->ml_peer_id)
>> +			return peer;
>> +
>> +	return NULL;
>> +}
>> +
>>  struct ath12k_peer *ath12k_peer_find_by_id(struct ath12k_base *ab,
>>  					   int peer_id)
>>  {
>> @@ -87,6 +101,9 @@ struct ath12k_peer *ath12k_peer_find_by_id(struct ath12k_base *ab,
>>  
>>  	lockdep_assert_held(&ab->base_lock);
>>  
>> +	if (peer_id & ATH12K_ML_PEER_ID_VALID)

[...]

> does other code elsewhere need to mask this bit off to have the "true" peer_id?

Based on my investigation the peer id is stored with
ATH12K_ML_PEER_ID_VALID so it should not be masked (unless I'm missing
something). This is not pretty but I guess keeps the code simpler.
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath12k/dp.h b/drivers/net/wireless/ath/ath12k/dp.h
index 2e05fc19410e..66b60f772efb 100644
--- a/drivers/net/wireless/ath/ath12k/dp.h
+++ b/drivers/net/wireless/ath/ath12k/dp.h
@@ -1796,6 +1796,8 @@  static inline void ath12k_dp_get_mac_addr(u32 addr_l32, u16 addr_h16, u8 *addr)
 	memcpy(addr + 4, &addr_h16, ETH_ALEN - 4);
 }
 
+#define ATH12K_ML_PEER_ID_VALID         BIT(13)
+
 int ath12k_dp_service_srng(struct ath12k_base *ab,
 			   struct ath12k_ext_irq_grp *irq_grp,
 			   int budget);
diff --git a/drivers/net/wireless/ath/ath12k/peer.c b/drivers/net/wireless/ath/ath12k/peer.c
index 39b371c7433c..c7eb60723d83 100644
--- a/drivers/net/wireless/ath/ath12k/peer.c
+++ b/drivers/net/wireless/ath/ath12k/peer.c
@@ -80,6 +80,20 @@  struct ath12k_peer *ath12k_peer_find_by_addr(struct ath12k_base *ab,
 	return NULL;
 }
 
+static struct ath12k_peer *ath12k_peer_find_by_ml_id(struct ath12k_base *ab,
+						     int ml_peer_id)
+{
+	struct ath12k_peer *peer;
+
+	lockdep_assert_held(&ab->base_lock);
+
+	list_for_each_entry(peer, &ab->peers, list)
+		if (ml_peer_id == peer->ml_peer_id)
+			return peer;
+
+	return NULL;
+}
+
 struct ath12k_peer *ath12k_peer_find_by_id(struct ath12k_base *ab,
 					   int peer_id)
 {
@@ -87,6 +101,9 @@  struct ath12k_peer *ath12k_peer_find_by_id(struct ath12k_base *ab,
 
 	lockdep_assert_held(&ab->base_lock);
 
+	if (peer_id & ATH12K_ML_PEER_ID_VALID)
+		return ath12k_peer_find_by_ml_id(ab, peer_id);
+
 	list_for_each_entry(peer, &ab->peers, list)
 		if (peer_id == peer->peer_id)
 			return peer;
diff --git a/drivers/net/wireless/ath/ath12k/peer.h b/drivers/net/wireless/ath/ath12k/peer.h
index b91bb2106b76..5b718fc5c795 100644
--- a/drivers/net/wireless/ath/ath12k/peer.h
+++ b/drivers/net/wireless/ath/ath12k/peer.h
@@ -47,6 +47,8 @@  struct ath12k_peer {
 
 	/* protected by ab->data_lock */
 	bool dp_setup_done;
+
+	u16 ml_peer_id;
 };
 
 struct ath12k_ml_peer {