1: 7981c137d36c ! 1: ab89c9960eb2 wifi: rtl8xxxu: move dynamic_tx_rpt_timing_counter from ra_info to priv @@ Commit message dynamic_tx_rpt_timing_counter is not per mac_id, but used across all mac_ids.  + This is the same as it is handled in other upstream drivers [1][2] which + support AP mode. + + This is a preparation for having one ra_info per mac_id. It does not + change anything for station mode. + + [1] https://github.com/lwfinger/rtl8188eu/blob/master/hal/Hal8188ERateAdaptive.c#L248 + [2] https://github.com/lwfinger/rtl8188eu/blob/v5.2.2.4/hal8188erateadaptive.c#L285 + + Signed-off-by: Georg Müller  + ## drivers/net/wireless/realtek/rtl8xxxu/8188e.c ##  @@ drivers/net/wireless/realtek/rtl8xxxu/8188e.c: static void rtl8188e_rate_decision(struct rtl8xxxu_ra_info *ra) } @@ drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h: struct rtl8xxxu_ra_info { u8 ra_pending_counter; u8 ra_drop_after_down;  @@ drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h: struct rtl8xxxu_priv { + struct rtl8xxxu_btcoex bt_coex; struct rtl8xxxu_ra_report ra_report; struct rtl8xxxu_cfo_tracking cfo_tracking; - struct rtl8xxxu_ra_info ra_info; -+ u8 dynamic_tx_rpt_timing_counter; // 8188e specific +- struct rtl8xxxu_ra_info ra_info; ++ struct rtl8xxxu_ra_info ra_info; /* 8188e specific */ ++ u8 dynamic_tx_rpt_timing_counter; /* 8188e specific */  bool led_registered; char led_name[32]; 2: acc4a79eede2 ! 2: 52e1856c4fee wifi: rtl8xxxu: handle rate control for 8188e a per mac_id @@ Metadata Author: Georg Müller   ## Commit message ## - wifi: rtl8xxxu: handle rate control for 8188e a per mac_id + wifi: rtl8xxxu: handle rate control per mac_id for 8188e  - convert member ra_info to an array with one entry per mac id. This + Convert member ra_info to an array with one entry per mac id. This allows having different rate control settings per connected station - in ap mode. + in AP mode.  The max_macid_num is conservative. The old driver used 32 [1], some other sources said 64 [2]. I have not enough adapters to test any of the @@ drivers/net/wireless/realtek/rtl8xxxu/8188e.c: void rtl8188e_handle_ra_tx_report u64 macid_valid = ((u64)_rx_desc[5] << 32) | _rx_desc[4];  @@ drivers/net/wireless/realtek/rtl8xxxu/8188e.c: void rtl8188e_handle_ra_tx_report2(struct rtl8xxxu_priv *priv, struct sk_buff *s  + dev_dbg(dev, "%s: len: %d items: %d\n", __func__, tx_rpt_len, items); +  +- /* We only use macid 0, so only the first item is relevant. +- * AP mode will use more of them if it's ever implemented. ++ /* In station mode we only use macid 0, so only the first item ++ * is relevant. In AP mode every station has its own macid. + */ + if (!priv->vifs[0] || priv->vifs[0]->type == NL80211_IFTYPE_STATION) + items = 1; ++ else ++ items = min_t(u32, items, RTL8188E_MAX_MAC_ID_NUM); +  for (macid = 0; macid < items; macid++) { valid = false;  + ra = &priv->ra_info[macid]; @@ drivers/net/wireless/realtek/rtl8xxxu/core.c: static int rtl8xxxu_init_device(st   - if (priv->rtl_chip == RTL8188E)  - rtl8188e_ra_info_init_all(&priv->ra_info); -- -+ if (priv->rtl_chip == RTL8188E) { -+ priv->ra_info = kmalloc_array(RTL8188E_MAX_MAC_ID_NUM, sizeof(*priv->ra_info), GFP_KERNEL); -+ if (!priv->ra_info) { -+ ret = -ENOMEM; -+ goto exit; -+ } -+ for (mac_id = 0; mac_id < RTL8188E_MAX_MAC_ID_NUM; mac_id++) { ++ if (priv->rtl_chip == RTL8188E) { ++ for (mac_id = 0; mac_id < RTL8188E_MAX_MAC_ID_NUM; mac_id++)  + rtl8188e_ra_info_init_all(&priv->ra_info[mac_id]); -+ }  + } +  set_bit(RTL8XXXU_BC_MC_MACID, priv->mac_id_map); set_bit(RTL8XXXU_BC_MC_MACID1, priv->mac_id_map); -   @@ drivers/net/wireless/realtek/rtl8xxxu/core.c: rtl8xxxu_fill_txdesc_v3(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr, { struct rtl8xxxu_priv *priv = hw->priv; @@ drivers/net/wireless/realtek/rtl8xxxu/core.c: rtl8xxxu_fill_txdesc_v3(struct iee u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; u32 rate = 0;  @@ drivers/net/wireless/realtek/rtl8xxxu/core.c: static int rtl8xxxu_probe(struct usb_interface *interface, - err_set_intfdata: - usb_set_intfdata(interface, NULL); -  -+ kfree(priv->ra_info); - kfree(priv->fw_data); - mutex_destroy(&priv->usb_buf_mutex); - mutex_destroy(&priv->syson_indirect_access_mutex); -@@ drivers/net/wireless/realtek/rtl8xxxu/core.c: static void rtl8xxxu_disconnect(struct usb_interface *interface) - usb_set_intfdata(interface, NULL); + goto err_set_intfdata; + }  - dev_info(&priv->udev->dev, "disconnecting\n"); -- -+ kfree(priv->ra_info); - kfree(priv->fw_data); - mutex_destroy(&priv->usb_buf_mutex); - mutex_destroy(&priv->syson_indirect_access_mutex); ++ if (priv->rtl_chip == RTL8188E) { ++ priv->ra_info = devm_kcalloc(&interface->dev, ++ RTL8188E_MAX_MAC_ID_NUM, ++ sizeof(*priv->ra_info), GFP_KERNEL); ++ if (!priv->ra_info) { ++ ret = -ENOMEM; ++ goto err_set_intfdata; ++ } ++ } ++ + ret = rtl8xxxu_init_device(hw); + if (ret) + goto err_set_intfdata;  ## drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ##  @@ @@ drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h: struct rtl8xxxu_priv { struct rtl8xxxu_btcoex bt_coex; struct rtl8xxxu_ra_report ra_report; struct rtl8xxxu_cfo_tracking cfo_tracking; -- struct rtl8xxxu_ra_info ra_info; -+ struct rtl8xxxu_ra_info *ra_info; - u8 dynamic_tx_rpt_timing_counter; // 8188e specific +- struct rtl8xxxu_ra_info ra_info; /* 8188e specific */ ++ struct rtl8xxxu_ra_info *ra_info; /* 8188e specific */ + u8 dynamic_tx_rpt_timing_counter; /* 8188e specific */  bool led_registered; 3: 39406debe519 ! 3: 1ecd2d22e50c wifi: rtl8xxxu: update max report mac id on station add / remove for 8188e chips @@ Metadata ## Commit message ## wifi: rtl8xxxu: update max report mac id on station add / remove for 8188e chips  + The 8188e only includes the mac ids below the value in + REG_TX_REPORT_CTRL + 1 in its type 2 TX report, which is used for the + software rate control. rtl8xxxu_init_device() sets it to 2, which only + covers the mac ids used in station mode. + + In AP mode, every connected station gets its own mac id. Set the + register to the highest acquired mac id + 1 whenever a station is added + or removed, so the TX report contains the entries of all connected + stations. + + Signed-off-by: Georg Müller  + ## drivers/net/wireless/realtek/rtl8xxxu/core.c ##  @@ drivers/net/wireless/realtek/rtl8xxxu/core.c: void rtl8xxxu_init_burst(struct rtl8xxxu_priv *priv) rtl8xxxu_write8(priv, REG_RSV_CTRL, val8); @@ drivers/net/wireless/realtek/rtl8xxxu/core.c: static int rtl8xxxu_sta_add(struct return -ENOSPC; }  ++ if (priv->rtl_chip == RTL8188E && ++ sta_info->macid >= RTL8188E_MAX_MAC_ID_NUM) { ++ rtl8xxxu_release_macid(priv, sta_info->macid); ++ mutex_unlock(&priv->sta_mutex); ++ return -ENOSPC; ++ } ++  + if (priv->rtl_chip == RTL8188E) {  + max_mac_id = rtl8xxxu_max_acquired_macid(priv);  + rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL + 1, max_mac_id + 1); 4: d6050c9f0c7f < -: ------------ wifi: rtl8xxxu: Enable AP mode for RTL8188EU -: ------------ > 4: db433cbb7561 wifi: rtl8xxxu: Enable AP mode for RTL8188EU -: ------------ > 5: 05d4ffa425fc wifi: rtl8xxxu: set macid in TX descriptor for 8188e