Skip to content

Commit da21d44

Browse files
authored
Merge pull request #369 from Shnimlz/fix-kernel-7.1-compat
Fix compatibility with Linux 6.9+ and 7.1+
2 parents 0877138 + e3520aa commit da21d44

2 files changed

Lines changed: 49 additions & 18 deletions

File tree

‎core/rtw_br_ext.c‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
#include <linux/atalk.h>
2424
#include <linux/udp.h>
2525
#include <linux/if_pppox.h>
26+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 9, 0))
27+
#define pppoe_tag_data(tag) ((char *)(tag) + sizeof(struct pppoe_tag))
28+
#define pppoe_hdr_tag(ph) ((struct pppoe_tag *)((char *)(ph) + sizeof(struct pppoe_hdr)))
29+
#else
30+
#define pppoe_tag_data(tag) ((tag)->tag_data)
31+
#define pppoe_hdr_tag(ph) ((ph)->tag)
32+
#endif
2633
#endif
2734

2835
#if 1 /* rtw_wifi_driver */
@@ -88,7 +95,7 @@ static unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, unsigned shor
8895
unsigned char *cur_ptr, *start_ptr;
8996
unsigned short tagLen, tagType;
9097

91-
start_ptr = cur_ptr = (unsigned char *)ph->tag;
98+
start_ptr = cur_ptr = (unsigned char *)pppoe_hdr_tag(ph);
9299
while ((cur_ptr - start_ptr) < ntohs(ph->length)) {
93100
/* prevent un-alignment access */
94101
tagType = (unsigned short)((cur_ptr[0] << 8) + cur_ptr[1]);
@@ -114,9 +121,9 @@ static int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag)
114121

115122
skb_put(skb, data_len);
116123
/* have a room for new tag */
117-
memmove(((unsigned char *)ph->tag + data_len), (unsigned char *)ph->tag, ntohs(ph->length));
124+
memmove(((unsigned char *)pppoe_hdr_tag(ph) + data_len), (unsigned char *)pppoe_hdr_tag(ph), ntohs(ph->length));
118125
ph->length = htons(ntohs(ph->length) + data_len);
119-
memcpy((unsigned char *)ph->tag, tag, data_len);
126+
memcpy((unsigned char *)pppoe_hdr_tag(ph), tag, data_len);
120127
return data_len;
121128
}
122129

@@ -1143,8 +1150,8 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
11431150
return -1;
11441151
}
11451152

1146-
memcpy(tag->tag_data + MAGIC_CODE_LEN + RTL_RELAY_TAG_LEN,
1147-
pOldTag->tag_data, old_tag_len);
1153+
memcpy(pppoe_tag_data(tag) + MAGIC_CODE_LEN + RTL_RELAY_TAG_LEN,
1154+
pppoe_tag_data(pOldTag), old_tag_len);
11481155

11491156
if (skb_pull_and_merge(skb, (unsigned char *)pOldTag, TAG_HDR_LEN + old_tag_len) < 0) {
11501157
DEBUG_ERR("call skb_pull_and_merge() failed in PADI/R packet!\n");
@@ -1157,9 +1164,9 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
11571164
tag->tag_len = htons(MAGIC_CODE_LEN + RTL_RELAY_TAG_LEN + old_tag_len);
11581165

11591166
/* insert the magic_code+client mac in relay tag */
1160-
pMagic = (unsigned short *)tag->tag_data;
1167+
pMagic = (unsigned short *)pppoe_tag_data(tag);
11611168
*pMagic = htons(MAGIC_CODE);
1162-
memcpy(tag->tag_data + MAGIC_CODE_LEN, skb->data + ETH_ALEN, ETH_ALEN);
1169+
memcpy(pppoe_tag_data(tag) + MAGIC_CODE_LEN, skb->data + ETH_ALEN, ETH_ALEN);
11631170

11641171
/* Add relay tag */
11651172
if (__nat25_add_pppoe_tag(skb, tag) < 0)
@@ -1220,14 +1227,14 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
12201227
return -1;
12211228
}
12221229

1223-
pMagic = (unsigned short *)tag->tag_data;
1230+
pMagic = (unsigned short *)pppoe_tag_data(tag);
12241231
if (ntohs(*pMagic) != MAGIC_CODE) {
12251232
DEBUG_ERR("Can't find MAGIC_CODE in %s packet!\n",
12261233
(ph->code == PADO_CODE ? "PADO" : "PADS"));
12271234
return -1;
12281235
}
12291236

1230-
memcpy(skb->data, tag->tag_data + MAGIC_CODE_LEN, ETH_ALEN);
1237+
memcpy(skb->data, pppoe_tag_data(tag) + MAGIC_CODE_LEN, ETH_ALEN);
12311238

12321239
if (tagLen > MAGIC_CODE_LEN + RTL_RELAY_TAG_LEN)
12331240
offset = TAG_HDR_LEN;

‎os_dep/linux/ioctl_cfg80211.c‎

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
#include <hal_data.h>
1919

2020
#ifdef CONFIG_IOCTL_CFG80211
21+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0))
22+
#define RTW_WDEV_ARG struct wireless_dev *wdev
23+
#define RTW_WDEV_GET struct net_device *ndev = wdev->netdev
24+
#else
25+
#define RTW_WDEV_ARG struct net_device *ndev
26+
#define RTW_WDEV_GET
27+
#endif
2128

2229
#ifndef DBG_RTW_CFG80211_STA_PARAM
2330
#define DBG_RTW_CFG80211_STA_PARAM 0
@@ -1700,7 +1707,7 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param
17001707
return ret;
17011708
}
17021709

1703-
static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev
1710+
static int cfg80211_rtw_add_key(struct wiphy *wiphy, RTW_WDEV_ARG
17041711
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
17051712
,int link_id
17061713
#endif
@@ -1710,6 +1717,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev
17101717
#endif
17111718
, const u8 *mac_addr, struct key_params *params)
17121719
{
1720+
RTW_WDEV_GET;
17131721
char *alg_name;
17141722
u32 param_len;
17151723
struct ieee_param *param = NULL;
@@ -1847,7 +1855,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev
18471855

18481856
}
18491857

1850-
static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev
1858+
static int cfg80211_rtw_get_key(struct wiphy *wiphy, RTW_WDEV_ARG
18511859
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
18521860
,int link_id
18531861
#endif
@@ -1858,6 +1866,7 @@ static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev
18581866
, const u8 *mac_addr, void *cookie
18591867
, void (*callback)(void *cookie, struct key_params *))
18601868
{
1869+
RTW_WDEV_GET;
18611870
#define GET_KEY_PARAM_FMT_S " keyid=%d"
18621871
#define GET_KEY_PARAM_ARG_S , keyid
18631872
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE)
@@ -2015,7 +2024,7 @@ static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev
20152024
return ret;
20162025
}
20172026

2018-
static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev,
2027+
static int cfg80211_rtw_del_key(struct wiphy *wiphy, RTW_WDEV_ARG,
20192028
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
20202029
int link_id,
20212030
#endif
@@ -2025,6 +2034,7 @@ static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev,
20252034
u8 key_index, const u8 *mac_addr)
20262035
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) */
20272036
{
2037+
RTW_WDEV_GET;
20282038
_adapter *padapter = (_adapter *)rtw_netdev_priv(ndev);
20292039
struct security_priv *psecuritypriv = &padapter->securitypriv;
20302040

@@ -2091,12 +2101,13 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy,
20912101

20922102
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30))
20932103
int cfg80211_rtw_set_default_mgmt_key(struct wiphy *wiphy,
2094-
struct net_device *ndev,
2104+
RTW_WDEV_ARG,
20952105
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
20962106
int link_id,
20972107
#endif
20982108
u8 key_index)
20992109
{
2110+
RTW_WDEV_GET;
21002111
#define SET_DEF_KEY_PARAM_FMT " key_index=%d"
21012112
#define SET_DEF_KEY_PARAM_ARG , key_index
21022113

@@ -2241,14 +2252,15 @@ static void rtw_cfg80211_fill_mesh_only_sta_info(struct mesh_plink_ent *plink, s
22412252
#endif /* CONFIG_RTW_MESH */
22422253

22432254
static int cfg80211_rtw_get_station(struct wiphy *wiphy,
2244-
struct net_device *ndev,
2255+
RTW_WDEV_ARG,
22452256
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0))
22462257
u8 *mac,
22472258
#else
22482259
const u8 *mac,
22492260
#endif
22502261
struct station_info *sinfo)
22512262
{
2263+
RTW_WDEV_GET;
22522264
int ret = 0;
22532265
_adapter *padapter = (_adapter *)rtw_netdev_priv(ndev);
22542266
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -4401,7 +4413,11 @@ void rtw_cfg80211_indicate_sta_assoc(_adapter *padapter, u8 *pmgmt_frame, uint f
44014413
sinfo.filled = STATION_INFO_ASSOC_REQ_IES;
44024414
sinfo.assoc_req_ies = pmgmt_frame + WLAN_HDR_A3_LEN + ie_offset;
44034415
sinfo.assoc_req_ies_len = frame_len - WLAN_HDR_A3_LEN - ie_offset;
4416+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0))
4417+
cfg80211_new_sta(padapter->rtw_wdev, get_addr2_ptr(pmgmt_frame), &sinfo, GFP_ATOMIC);
4418+
#else
44044419
cfg80211_new_sta(ndev, get_addr2_ptr(pmgmt_frame), &sinfo, GFP_ATOMIC);
4420+
#endif
44054421
}
44064422
#else /* defined(RTW_USE_CFG80211_STA_EVENT) */
44074423
channel = pmlmeext->cur_channel;
@@ -4447,7 +4463,11 @@ void rtw_cfg80211_indicate_sta_disassoc(_adapter *padapter, const u8 *da, unsign
44474463
RTW_INFO(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
44484464

44494465
#if defined(RTW_USE_CFG80211_STA_EVENT) || defined(COMPAT_KERNEL_RELEASE)
4466+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(7, 1, 0))
4467+
cfg80211_del_sta(padapter->rtw_wdev, da, GFP_ATOMIC);
4468+
#else
44504469
cfg80211_del_sta(ndev, da, GFP_ATOMIC);
4470+
#endif
44514471
#else /* defined(RTW_USE_CFG80211_STA_EVENT) */
44524472
channel = pmlmeext->cur_channel;
44534473
freq = rtw_ch2freq(channel);
@@ -5368,14 +5388,15 @@ void dump_station_parameters(void *sel, struct wiphy *wiphy, const struct statio
53685388
#endif /* DBG_RTW_CFG80211_STA_PARAM */
53695389
}
53705390

5371-
static int cfg80211_rtw_add_station(struct wiphy *wiphy, struct net_device *ndev,
5391+
static int cfg80211_rtw_add_station(struct wiphy *wiphy, RTW_WDEV_ARG,
53725392
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0))
53735393
u8 *mac,
53745394
#else
53755395
const u8 *mac,
53765396
#endif
53775397
struct station_parameters *params)
53785398
{
5399+
RTW_WDEV_GET;
53795400
int ret = 0;
53805401
_adapter *padapter = (_adapter *)rtw_netdev_priv(ndev);
53815402
#if defined(CONFIG_TDLS) || defined(CONFIG_RTW_MESH)
@@ -5536,7 +5557,7 @@ static int cfg80211_rtw_add_station(struct wiphy *wiphy, struct net_device *ndev
55365557
return ret;
55375558
}
55385559

5539-
static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev,
5560+
static int cfg80211_rtw_del_station(struct wiphy *wiphy, RTW_WDEV_ARG,
55405561
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0))
55415562
u8 *mac
55425563
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0))
@@ -5546,6 +5567,7 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev
55465567
#endif
55475568
)
55485569
{
5570+
RTW_WDEV_GET;
55495571
int ret = 0;
55505572
_irqL irqL;
55515573
_list *phead, *plist;
@@ -5642,14 +5664,15 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev
56425664

56435665
}
56445666

5645-
static int cfg80211_rtw_change_station(struct wiphy *wiphy, struct net_device *ndev,
5667+
static int cfg80211_rtw_change_station(struct wiphy *wiphy, RTW_WDEV_ARG,
56465668
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0))
56475669
u8 *mac,
56485670
#else
56495671
const u8 *mac,
56505672
#endif
56515673
struct station_parameters *params)
56525674
{
5675+
RTW_WDEV_GET;
56535676
#ifdef CONFIG_RTW_MESH
56545677
_adapter *adapter = (_adapter *)rtw_netdev_priv(ndev);
56555678
struct sta_priv *stapriv = &adapter->stapriv;
@@ -5796,9 +5819,10 @@ struct sta_info *rtw_sta_info_get_by_idx(struct sta_priv *pstapriv, const int id
57965819
return psta;
57975820
}
57985821

5799-
static int cfg80211_rtw_dump_station(struct wiphy *wiphy, struct net_device *ndev,
5822+
static int cfg80211_rtw_dump_station(struct wiphy *wiphy, RTW_WDEV_ARG,
58005823
int idx, u8 *mac, struct station_info *sinfo)
58015824
{
5825+
RTW_WDEV_GET;
58025826
#define DBG_DUMP_STATION 0
58035827

58045828
int ret = 0;

0 commit comments

Comments
 (0)