-: ------------ > 1: f8ba75b7b4ea wifi: mac80211: compute the airtime estimate in 64 bits -: ------------ > 2: 365745aa1a5d wifi: mac80211: use the ampdu argument of ieee80211_calc_expected_tx_airtime() -: ------------ > 3: 29071fefa06a wifi: mac80211: clamp the AQL airtime estimate before narrowing it 1: e66840850573 ! 4: f716077e3bb3 wifi: mac80211: advertise TSO and SG for encap offloaded frames @@ Commit message applies to every netdev of the hw, so a feature set there also reaches the frames that go out through the 802.11 path.  - Add hw->encap_netdev_features and hw->encap_gso_max_segs. mac80211 sets - the features on the AP, AP_VLAN and station netdevs when the hw supports - encap offload, and ieee80211_8023_xmit() passes them to - ieee80211_tx_skb_fixup(), so a GSO frame reaches the driver whole. The - 802.11 path keeps using the features of the vif, which do not include - them, and segments such a frame in software as before. + Add hw->encap_netdev_features and hw->encap_gso_max_segs. When the hw + supports encap offload, mac80211 sets the features on each netdev it + creates, and ieee80211_8023_xmit() passes them to + ieee80211_tx_skb_fixup(), so a GSO frame reaches the driver whole. + + Whether a netdev sends with encap offload changes with its type, 4addr + mode, fragmentation threshold and monitor interfaces, and mac80211 + switches its netdev ops when it does. The ops of the 802.11 and monitor + paths get an ndo_features_check that drops the encap features, so the + stack segments, linearizes and resolves the checksum first.  AQL charges a frame by tx_time_est, which ieee80211_info_set_tx_time_est() - caps at 4095 us. A whole GSO frame to a slow station can take longer and - would be charged less than its airtime. Segment such a frame in software - instead. + caps at 4095 us. A whole GSO frame to a slow station, or to one whose + rate mac80211 does not know yet, would be charged less than its + airtime. Segment such a frame in software instead; the segments keep + scatter-gather. The check uses the rate of the station when the frame + is queued.  The tx statistics count a TCP GSO frame as gso_segs packets, with the headers of every segment in its length. @@ include/net/mac80211.h: enum ieee80211_hw_flags { * from this HW. Note that not all features are usable with mac80211, * other features will be rejected during HW registration.  + * @encap_netdev_features: netdev features, in addition to @netdev_features, -+ * set in each AP, AP VLAN and station netdev created from this HW, for -+ * the frames that are sent with 802.3 encapsulation offload (see ++ * set in each netdev created from this HW when it supports 802.3 ++ * encapsulation offload, for the frames that are sent with it (see  + * %IEEE80211_OFFLOAD_ENCAP_ENABLED). A driver sets scatter-gather and  + * segmentation offload here when the hardware takes such frames whole.  + * mac80211 hands a driver a frame with these features only with  + * %IEEE80211_TX_CTL_HW_80211_ENCAP, and segments or linearizes it in  + * software on every other path, and for a station when the airtime  + * estimate of the whole frame is more than AQL can account to one frame. -+ * Such a frame starts with its 802.3 header; a GSO frame has at most -+ * @encap_gso_max_segs segments. ++ * Such a frame starts with its 802.3 header.  + * @encap_gso_max_segs: the most segments of a GSO frame the driver takes -+ * whole, when @encap_netdev_features has a segmentation offload. ++ * whole, when @encap_netdev_features has a segmentation offload; 0 ++ * keeps the default limit of the netdev. * * @uapsd_queues: This bitmap is included in (re)association frame to indicate * for each access category if it is uAPSD trigger-enabled and delivery- @@ include/net/mac80211.h: struct ieee80211_hw { u8 max_nan_de_entries;  ## net/mac80211/iface.c ## +@@ + #include  + #include  + #include  ++#include  + #include  + #include  + #include  +@@ net/mac80211/iface.c: static int ieee80211_netdev_setup_tc(struct net_device *dev, + return drv_net_setup_tc(local, sdata, dev, type, type_data); + } +  ++/* For the netdev ops that send without the 802.3 encap offload: the frame ++ * is built into an 802.11 frame here, which cannot take what only the encap ++ * offload path takes, so the stack segments or linearizes it first. ++ */ ++static netdev_features_t ++ieee80211_netdev_features_check(struct sk_buff *skb, struct net_device *dev, ++ netdev_features_t features) ++{ ++ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); ++ struct ieee80211_hw *hw = &sdata->local->hw; ++ ++ features &= ~(hw->encap_netdev_features & ~hw->netdev_features); ++ ++ return vlan_features_check(skb, features); ++} ++ + static const struct net_device_ops ieee80211_dataif_ops = { + .ndo_open = ieee80211_open, + .ndo_stop = ieee80211_stop, + .ndo_uninit = ieee80211_uninit, + .ndo_start_xmit = ieee80211_subif_start_xmit, ++ .ndo_features_check = ieee80211_netdev_features_check, + .ndo_set_rx_mode = ieee80211_set_multicast_list, + .ndo_set_mac_address = ieee80211_change_mac, + .ndo_setup_tc = ieee80211_netdev_setup_tc, +@@ net/mac80211/iface.c: static const struct net_device_ops ieee80211_monitorif_ops = { + .ndo_stop = ieee80211_stop, + .ndo_uninit = ieee80211_uninit, + .ndo_start_xmit = ieee80211_monitor_start_xmit, ++ .ndo_features_check = ieee80211_netdev_features_check, + .ndo_set_rx_mode = ieee80211_set_multicast_list, + .ndo_set_mac_address = ieee80211_change_mac, + .ndo_select_queue = ieee80211_monitor_select_queue,  @@ net/mac80211/iface.c: int ieee80211_if_add(struct ieee80211_local *local, const char *name, sdata->u.mgd.use_4addr = params->use_4addr;  ndev->features |= local->hw.netdev_features; -+ /* Only the netdevs that can use the encap offload offer its -+ * features: every other path segments in software, with the -+ * features of the vif. ++ /* ieee80211_netdev_features_check() takes the encap features ++ * away from every frame sent without the encap offload  + */ -+ if (ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD) && -+ local->hw.encap_netdev_features && -+ (type == NL80211_IFTYPE_AP || -+ type == NL80211_IFTYPE_AP_VLAN || -+ type == NL80211_IFTYPE_STATION)) { ++ if (ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD)) {  + ndev->features |= local->hw.encap_netdev_features;  + if (local->hw.encap_gso_max_segs)  + netif_set_tso_max_segs(ndev, @@ net/mac80211/tx.c: static bool ieee80211_tx_8023(struct ieee80211_sub_if_data *s }   +/* A frame's airtime estimate has 10 bits, in units of 4 us. A GSO frame whose -+ * estimate would not fit is charged less than it takes and stays in the AQL -+ * limits for as long as it takes, so it is segmented in software instead. ++ * estimate would not fit, or that has no estimate because the rate of the ++ * station is not known, is charged less than it takes, so it is segmented in ++ * software instead.  + */  +#define IEEE80211_TX_GSO_AIRTIME_MAX 4092  + @@ net/mac80211/tx.c: static bool ieee80211_tx_8023(struct ieee80211_sub_if_data *s  + u16 queue)  +{  + struct ieee80211_local *local = sdata->local; ++ struct ieee80211_chanctx_conf *conf;  + u32 airtime; ++ u8 band = 0;  +  + if (!sta || !wiphy_ext_feature_isset(local->hw.wiphy,  + NL80211_EXT_FEATURE_AQL)) @@ net/mac80211/tx.c: static bool ieee80211_tx_8023(struct ieee80211_sub_if_data *s  + sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,  + u.ap);  + -+ airtime = ieee80211_calc_expected_tx_airtime(&local->hw, &sdata->vif, -+ &sta->sta, skb->len, -+ queue != IEEE80211_AC_VO); ++ /* the estimate of ieee80211_calc_expected_tx_airtime(), which charges ++ * 4 us when it has no rate to estimate with ++ */ ++ conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); ++ if (conf) ++ band = conf->def.chan->band; ++ ++ airtime = ieee80211_rate_expected_tx_airtime(&local->hw, ++ &sta->deflink.tx_stats.last_rate, ++ &sta->deflink.tx_stats.last_rate_info, ++ band, queue != IEEE80211_AC_VO, ++ skb->len + 38);  + -+ return airtime <= IEEE80211_TX_GSO_AIRTIME_MAX; ++ return airtime && airtime / 1024 <= IEEE80211_TX_GSO_AIRTIME_MAX;  +}  + static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata, @@ net/mac80211/tx.c: static void ieee80211_8023_xmit(struct ieee80211_sub_if_data  + features = ieee80211_sdata_netdev_features(sdata) |  + local->hw.encap_netdev_features;  + if (skb_is_gso(skb) && !ieee80211_8023_gso_fits(sdata, sta, skb, queue)) -+ features &= ~(NETIF_F_ALL_TSO | NETIF_F_SG); ++ features &= ~NETIF_F_GSO_MASK;  +  + skb = ieee80211_tx_skb_fixup(skb, features); if (!skb) 2: 6d75465addfc = 5: 5a263accdcf1 wifi: mac80211: take the TID of an 802.3 frame from the driver 3: ad149afbfdd9 < -: ------------ wifi: ath11k: pass the TID of a received 802.3 frame to mac80211 4: bab231dba7bf < -: ------------ wifi: ath12k: pass the TID of a received 802.3 frame to mac80211 -: ------------ > 6: 78c2880275a9 wifi: ath11k: pass the TID of a received 802.3 frame to mac80211 -: ------------ > 7: a1614e872a61 wifi: ath12k: pass the TID of a received 802.3 frame to mac80211