Re: [PATCH v3 01/13] mac80211: rework tx encapsulation offload API

Felix Fietkau
2020-08-27T14:43:08Z

On 2020-08-27 14:42, Johannes Berg wrote:
>
> I was going to not worry about it, but now that I'm replying anyway ...
>
>> +++ b/net/mac80211/iface.c
>> @@ -43,6 +43,7 @@
>> */
>>
>> static void ieee80211_iface_work(struct work_struct *work);
>> +static void ieee80211_set_vif_encap_ops(struct ieee80211_sub_if_data *sdata);
>
> Do we really need that, can can't reorder things?
I can try, but the reorder might get messy, since I'd have to move up
ieee80211_dataif_ops and ieee80211_dataif_8023_ops, along with some
functions that they reference.
My preference was to not move around so much code, which is why I added
this line.

>> +static bool ieee80211_iftype_supports_encap_offload(enum nl80211_iftype iftype)
>> +{
>> + switch (iftype) {
>> + case NL80211_IFTYPE_AP:
>> + case NL80211_IFTYPE_P2P_GO:
>> + case NL80211_IFTYPE_P2P_CLIENT:
>
> The P2P ones cannot happen here due to the iftype munging that mac80211
> does, suggest you add a comment about that and remove them.
Okay, will remove them. Do you want me to send v2 of just this patch, or
the full series?

>> + list_for_each_entry(key, &sdata->key_list, list) {
>> + if (key->conf.cipher == WLAN_CIPHER_SUITE_AES_CMAC ||
>> + key->conf.cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 ||
>> + key->conf.cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256 ||
>> + key->conf.cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256)
>> + continue;
>
> I had to read that a few times to understand it ... maybe add a comment
> that the management frame keys aren't relevant? :)
Sure, will add it.

> But anyway, what I was really not sure about is this function:
>
>> +static void ieee80211_set_vif_encap_ops(struct ieee80211_sub_if_data *sdata)
>> +{
>> + struct ieee80211_local *local = sdata->local;
>> + struct ieee80211_sub_if_data *bss = sdata;
>> + struct ieee80211_key *key;
>> + bool enabled;
>> +
>> + if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
>> + if (!sdata->bss)
>> + return;
>> +
>> + bss = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap);
>> + }
>> +
>> + if (!ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD) ||
>> + !ieee80211_iftype_supports_encap_offload(bss->vif.type))
>> + return;
>
> There are a lot of returns here, some of which make sense, but the
> sdata->bss one seems dynamic and doesn't really make sense? Could it
> change?
>
> Or maybe we don't care because if it's not linked to a BSS it cannot be
> transmitting?
I think sdata->bss can be NULL while the AP_VLAN is down. We can't check
offload state in that case, so we should return here.
ieee80211_set_vif_encap_ops will be called for this AP_VLAN again from
ieee80211_do_open, when it is brought up and sdata->bss will then be set.

- Felix