diff mbox series

[2/2] wifi: mac80211: VLAN unicast packets take 8023 xmit path

Message ID 20240506212014.670423-3-quic_msinada@quicinc.com (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show
Series Allow VLAN unicast packets to take 8023 xmit path | expand

Commit Message

Muna Sinada May 6, 2024, 9:20 p.m. UTC
Default behavior for multicast AP VLAN interface traffic is using
software encryption as per commit 18890d4b89d8 ("mac80211: Disable hw
crypto for GTKs on AP VLAN interfaces").

When encapsulation offload is enabled, non-VLAN AP unicast packets are
taking the 8023 xmit path. Similarly unicast packets in AP VLAN
interfaces should have the same behavior as the non-VLAN AP case.

Allow AP VLAN unicast packets to take the 8023 xmit path where
hardware will handle encapsulation and encryption. As a result, there
is less CPU overhead in the 8023 xmit path as we don't encapsulate in
software. Mcast/bcast will continue to use 80211 xmit path.

Co-developed-by: Gautham Kumar Senthilkumaran <quic_gauthamk@quicinc.com>
Signed-off-by: Gautham Kumar Senthilkumaran <quic_gauthamk@quicinc.com>
Signed-off-by: Muna Sinada <quic_msinada@quicinc.com>
---
 net/mac80211/tx.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Johannes Berg May 7, 2024, 6:50 a.m. UTC | #1
On Mon, 2024-05-06 at 14:20 -0700, Muna Sinada wrote:
> 
> +	if (sta && sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
> +		ap_sdata = container_of(sdata->bss,
> +					struct ieee80211_sub_if_data, u.ap);
> +		if (ap_sdata->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED &&
> +		    !is_multicast_ether_addr(skb->data)) {
> +			key = rcu_dereference(sta->ptk[sta->ptk_idx]);

Why is that line there, and why is it necessary? Is it even correct?

I see you need a key pointer on the next line, but still... that doesn't
seem right.

johannes
diff mbox series

Patch

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index c0e0b5f63714..d77172771a36 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -4654,7 +4654,9 @@  void __ieee80211_subif_start_xmit(struct sk_buff *skb,
 				  u64 *cookie)
 {
 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+	struct ieee80211_sub_if_data *ap_sdata;
 	struct ieee80211_local *local = sdata->local;
+	struct ieee80211_key *key;
 	struct sta_info *sta;
 	struct sk_buff *next;
 	int len = skb->len;
@@ -4679,6 +4681,17 @@  void __ieee80211_subif_start_xmit(struct sk_buff *skb,
 	if (IS_ERR(sta))
 		sta = NULL;
 
+	if (sta && sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
+		ap_sdata = container_of(sdata->bss,
+					struct ieee80211_sub_if_data, u.ap);
+		if (ap_sdata->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED &&
+		    !is_multicast_ether_addr(skb->data)) {
+			key = rcu_dereference(sta->ptk[sta->ptk_idx]);
+			ieee80211_8023_xmit(sdata, dev, sta, key, skb);
+			goto out;
+		}
+	}
+
 	skb_set_queue_mapping(skb, ieee80211_select_queue(sdata, sta, skb));
 	ieee80211_aggr_check(sdata, sta, skb);