]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtw89: use ieee80211_tx_info::driver_data to store driver TX info
authorPing-Ke Shih <pkshih@realtek.com>
Mon, 15 Sep 2025 06:52:04 +0000 (14:52 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Thu, 18 Sep 2025 01:11:39 +0000 (09:11 +0800)
It makes more sense to use ieee80211_tx_info::driver_data instead of
ieee80211_tx_info::status.status_driver_data which is used to share
TX status reporting to mac80211, because actually driver calls
ieee80211_tx_info_clear_status() to clear the content including
status_driver_data in rtw89_pci_tx_status() before filling the status.

Review and point out the scope (by comments) driver can safely use
ieee80211_tx_info::driver_data between rtw89_hci_tx_write() and
calling ieee80211_tx_info_clear_status().

Add BUILD_BUG_ON() to assert that driver struct size is smaller than
the size defined by mac80211.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250915065213.38659-3-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/core.h
drivers/net/wireless/realtek/rtw89/pci.h

index ecfbcff85047194b733ab4a472b0fee83a844955..2841ea84bbc0af2d2a0ca8d8c507a31c14b994e2 100644 (file)
@@ -6390,9 +6390,13 @@ static inline void rtw89_hci_clear(struct rtw89_dev *rtwdev, struct pci_dev *pde
 static inline
 struct rtw89_tx_skb_data *RTW89_TX_SKB_CB(struct sk_buff *skb)
 {
+       /*
+        * This should be used by/after rtw89_hci_tx_write() and before doing
+        * ieee80211_tx_info_clear_status().
+        */
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
 
-       return (struct rtw89_tx_skb_data *)info->status.status_driver_data;
+       return (struct rtw89_tx_skb_data *)info->driver_data;
 }
 
 static inline u8 rtw89_read8(struct rtw89_dev *rtwdev, u32 addr)
index fc8268eb44db5361f570473135b50d5edeb65612..cb05c83dfd567ed717221c9806289f6240a488d2 100644 (file)
@@ -1634,10 +1634,7 @@ struct rtw89_pci {
 
 static inline struct rtw89_pci_rx_info *RTW89_PCI_RX_SKB_CB(struct sk_buff *skb)
 {
-       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
-
-       BUILD_BUG_ON(sizeof(struct rtw89_pci_tx_data) >
-                    sizeof(info->status.status_driver_data));
+       BUILD_BUG_ON(sizeof(struct rtw89_pci_rx_info) > sizeof(skb->cb));
 
        return (struct rtw89_pci_rx_info *)skb->cb;
 }
@@ -1668,6 +1665,10 @@ static inline struct rtw89_pci_tx_data *RTW89_PCI_TX_SKB_CB(struct sk_buff *skb)
 {
        struct rtw89_tx_skb_data *data = RTW89_TX_SKB_CB(skb);
 
+       BUILD_BUG_ON(sizeof(struct rtw89_tx_skb_data) +
+                    sizeof(struct rtw89_pci_tx_data) >
+                    sizeof_field(struct ieee80211_tx_info, driver_data));
+
        return (struct rtw89_pci_tx_data *)data->hci_priv;
 }