wifi: rtw89: use ieee80211_tx_info::driver_data to store driver TX info

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
This commit is contained in:
Ping-Ke Shih 2025-09-15 14:52:04 +08:00
parent df3d55a63f
commit 19989c8073
2 changed files with 10 additions and 5 deletions

View 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)

View 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;
}