Skip to content

Commit 2ffeeea

Browse files
committed
Enable cfg80211 support
1 parent a28dbcb commit 2ffeeea

File tree

10 files changed

+83
-26
lines changed

10 files changed

+83
-26
lines changed

drivers/net/wireless/realtek/rtl8192cu/core/rtw_ioctl_set.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extern void indicate_wx_scan_complete_event(_adapter *padapter);
4343
(addr[4] == 0xff) && (addr[5] == 0xff) ) ? _TRUE : _FALSE \
4444
)
4545

46-
u8 rtw_validate_bssid(u8 *bssid)
46+
u8 rtw_validate_bssid(const u8 *bssid)
4747
{
4848
u8 ret = _TRUE;
4949

@@ -535,7 +535,7 @@ _func_exit_;
535535

536536
}
537537

538-
u8 rtw_set_802_11_connect(_adapter* padapter, u8 *bssid, NDIS_802_11_SSID *ssid)
538+
u8 rtw_set_802_11_connect(_adapter* padapter, const u8 *bssid, NDIS_802_11_SSID *ssid)
539539
{
540540
_irqL irqL;
541541
u8 status = _SUCCESS;

drivers/net/wireless/realtek/rtl8192cu/core/rtw_sta_mgt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ _func_exit_;
685685
}
686686

687687
/* any station allocated can be searched by hash list */
688-
struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
688+
struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, const u8 *hwaddr)
689689
{
690690

691691
_irqL irqL;
@@ -696,7 +696,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
696696

697697
u32 index;
698698

699-
u8 *addr;
699+
const u8 *addr;
700700

701701
u8 bc_addr[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff};
702702

drivers/net/wireless/realtek/rtl8192cu/include/autoconf.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131

3232
#define PLATFORM_LINUX 1
3333

34-
//#define CONFIG_IOCTL_CFG80211 1
34+
#define CONFIG_IOCTL_CFG80211 1
3535
#ifdef CONFIG_IOCTL_CFG80211
36-
//#define RTW_USE_CFG80211_STA_EVENT /* Indecate new sta asoc through cfg80211_new_sta */
37-
#define CONFIG_CFG80211_FORCE_COMPATIBLE_2_6_37_UNDER
36+
#define RTW_USE_CFG80211_STA_EVENT /* Indecate new sta asoc through cfg80211_new_sta */
37+
//#define CONFIG_CFG80211_FORCE_COMPATIBLE_2_6_37_UNDER
3838
//#define CONFIG_DEBUG_CFG80211 1
3939
//#define CONFIG_DRV_ISSUE_PROV_REQ // IOT FOR S2
4040
#define CONFIG_SET_SCAN_DENY_TIMER

drivers/net/wireless/realtek/rtl8192cu/include/ioctl_cfg80211.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,13 @@ bool rtw_cfg80211_pwr_mgmt(_adapter *adapter);
149149
#define rtw_cfg80211_rx_mgmt(adapter, freq, sig_dbm, buf, len, gfp) cfg80211_rx_mgmt((adapter)->pnetdev, freq, buf, len, gfp)
150150
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
151151
#define rtw_cfg80211_rx_mgmt(adapter, freq, sig_dbm, buf, len, gfp) cfg80211_rx_mgmt((adapter)->pnetdev, freq, sig_dbm, buf, len, gfp)
152-
#else
152+
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0))
153153
#define rtw_cfg80211_rx_mgmt(adapter, freq, sig_dbm, buf, len, gfp) cfg80211_rx_mgmt((adapter)->rtw_wdev, freq, sig_dbm, buf, len, gfp)
154+
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0))
155+
// 3.12 added a flags argument which is just set to zero
156+
#define rtw_cfg80211_rx_mgmt(adapter, freq, sig_dbm, buf, len, gfp) cfg80211_rx_mgmt((adapter)->rtw_wdev, freq, sig_dbm, buf, len, 0, gfp)
157+
#else
158+
#define rtw_cfg80211_rx_mgmt(adapter, freq, sig_dbm, buf, len, gfp) cfg80211_rx_mgmt((adapter)->rtw_wdev, freq, sig_dbm, buf, len, 0)
154159
#endif
155160

156161
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) && !defined(COMPAT_KERNEL_RELEASE)

drivers/net/wireless/realtek/rtl8192cu/include/osdep_service.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,8 +1395,8 @@ void _rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dma_a
13951395
extern void* rtw_malloc2d(int h, int w, int size);
13961396
extern void rtw_mfree2d(void *pbuf, int h, int w, int size);
13971397

1398-
extern void _rtw_memcpy(void* dec, void* sour, u32 sz);
1399-
extern int _rtw_memcmp(void *dst, void *src, u32 sz);
1398+
extern void _rtw_memcpy(void* dec, const void* sour, u32 sz);
1399+
extern int _rtw_memcmp(const void *dst, const void *src, u32 sz);
14001400
extern void _rtw_memset(void *pbuf, int c, u32 sz);
14011401

14021402
extern void _rtw_init_listhead(_list *list);

drivers/net/wireless/realtek/rtl8192cu/include/rtw_ioctl_set.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ u8 rtw_set_802_11_bssid_list_scan(_adapter* padapter, NDIS_802_11_SSID *pssid, i
6363
u8 rtw_set_802_11_infrastructure_mode(_adapter * padapter, NDIS_802_11_NETWORK_INFRASTRUCTURE networktype);
6464
u8 rtw_set_802_11_remove_wep(_adapter * padapter, u32 keyindex);
6565
u8 rtw_set_802_11_ssid(_adapter * padapter, NDIS_802_11_SSID * ssid);
66-
u8 rtw_set_802_11_connect(_adapter* padapter, u8 *bssid, NDIS_802_11_SSID *ssid);
66+
u8 rtw_set_802_11_connect(_adapter* padapter, const u8 *bssid, NDIS_802_11_SSID *ssid);
6767
u8 rtw_set_802_11_remove_key(_adapter * padapter, NDIS_802_11_REMOVE_KEY * key);
6868

69-
u8 rtw_validate_bssid(u8 *bssid);
69+
u8 rtw_validate_bssid(const u8 *bssid);
7070
u8 rtw_validate_ssid(NDIS_802_11_SSID *ssid);
7171

7272
u16 rtw_get_cur_max_rate(_adapter *adapter);

drivers/net/wireless/realtek/rtl8192cu/include/sta_info.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ struct sta_priv {
395395
};
396396

397397

398-
__inline static u32 wifi_mac_hash(u8 *mac)
398+
__inline static u32 wifi_mac_hash(const u8 *mac)
399399
{
400400
u32 x;
401401

@@ -423,7 +423,7 @@ struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset)
423423
extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
424424
extern u32 rtw_free_stainfo(_adapter *padapter , struct sta_info *psta);
425425
extern void rtw_free_all_stainfo(_adapter *padapter);
426-
extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
426+
extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, const u8 *hwaddr);
427427
extern u32 rtw_init_bcmc_stainfo(_adapter* padapter);
428428
extern struct sta_info* rtw_get_bcmc_stainfo(_adapter* padapter);
429429
extern u8 rtw_access_ctrl(_adapter *padapter, u8 *mac_addr);

drivers/net/wireless/realtek/rtl8192cu/include/wifi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ enum WIFI_REG_DOMAIN {
425425
(addr[4] == 0xff) && (addr[5] == 0xff) ) ? _TRUE : _FALSE \
426426
)
427427

428-
__inline static int IS_MCAST(unsigned char *da)
428+
__inline static int IS_MCAST(const unsigned char *da)
429429
{
430430
if ((*da) & 0x01)
431431
return _TRUE;

drivers/net/wireless/realtek/rtl8192cu/os_dep/linux/ioctl_cfg80211.c

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -700,13 +700,16 @@ void rtw_cfg80211_indicate_disconnect(_adapter *padapter)
700700
if (!padapter->mlmepriv.not_indic_disco) {
701701
DBG_8192C("pwdev->sme_state(b)=%d\n", pwdev->sme_state);
702702

703-
if(pwdev->sme_state==CFG80211_SME_CONNECTING)
703+
if (check_fwstate(pmlmepriv, WIFI_UNDER_LINKING)) {
704704
cfg80211_connect_result(padapter->pnetdev, NULL, NULL, 0, NULL, 0,
705705
WLAN_STATUS_UNSPECIFIED_FAILURE, GFP_ATOMIC/*GFP_KERNEL*/);
706-
else if(pwdev->sme_state==CFG80211_SME_CONNECTED)
706+
} else {
707+
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
707708
cfg80211_disconnected(padapter->pnetdev, 0, NULL, 0, GFP_ATOMIC);
708-
//else
709-
//DBG_8192C("pwdev->sme_state=%d\n", pwdev->sme_state);
709+
#else
710+
cfg80211_disconnected(padapter->pnetdev, 0, NULL, 0, false, GFP_ATOMIC);
711+
#endif
712+
}
710713

711714
DBG_8192C("pwdev->sme_state(a)=%d\n", pwdev->sme_state);
712715
}
@@ -1549,7 +1552,7 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy,
15491552

15501553
static int cfg80211_rtw_get_station(struct wiphy *wiphy,
15511554
struct net_device *ndev,
1552-
u8 *mac, struct station_info *sinfo)
1555+
const u8 *mac, struct station_info *sinfo)
15531556
{
15541557
int ret = 0;
15551558
_adapter *padapter = wiphy_to_adapter(wiphy);
@@ -1589,16 +1592,32 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy,
15891592
goto exit;
15901593
}
15911594

1595+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0))
1596+
sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
1597+
#else
15921598
sinfo->filled |= STATION_INFO_SIGNAL;
1599+
#endif
15931600
sinfo->signal = translate_percentage_to_dbm(padapter->recvpriv.signal_strength);
15941601

1602+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0))
1603+
sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE);
1604+
#else
15951605
sinfo->filled |= STATION_INFO_TX_BITRATE;
1606+
#endif
15961607
sinfo->txrate.legacy = rtw_get_cur_max_rate(padapter);
15971608

1609+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0))
1610+
sinfo->filled |= BIT(NL80211_STA_INFO_RX_PACKETS);
1611+
#else
15981612
sinfo->filled |= STATION_INFO_RX_PACKETS;
1613+
#endif
15991614
sinfo->rx_packets = sta_rx_data_pkts(psta);
16001615

1616+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0))
1617+
sinfo->filled |= BIT(NL80211_STA_INFO_TX_PACKETS);
1618+
#else
16011619
sinfo->filled |= STATION_INFO_TX_PACKETS;
1620+
#endif
16021621
sinfo->tx_packets = psta->sta_stats.tx_pkts;
16031622

16041623
}
@@ -2419,7 +2438,7 @@ static int rtw_cfg80211_set_key_mgt(struct security_priv *psecuritypriv, u32 key
24192438
return 0;
24202439
}
24212440

2422-
static int rtw_cfg80211_set_wpa_ie(_adapter *padapter, u8 *pie, size_t ielen)
2441+
static int rtw_cfg80211_set_wpa_ie(_adapter *padapter, const u8 *pie, size_t ielen)
24232442
{
24242443
u8 *buf=NULL, *pos=NULL;
24252444
u32 left;
@@ -3089,7 +3108,9 @@ void rtw_cfg80211_indicate_sta_assoc(_adapter *padapter, u8 *pmgmt_frame, uint f
30893108
ie_offset = _REASOCREQ_IE_OFFSET_;
30903109

30913110
sinfo.filled = 0;
3111+
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0))
30923112
sinfo.filled = STATION_INFO_ASSOC_REQ_IES;
3113+
#endif
30933114
sinfo.assoc_req_ies = pmgmt_frame + WLAN_HDR_A3_LEN + ie_offset;
30943115
sinfo.assoc_req_ies_len = frame_len - WLAN_HDR_A3_LEN - ie_offset;
30953116
cfg80211_new_sta(ndev, GetAddr2Ptr(pmgmt_frame), &sinfo, GFP_ATOMIC);
@@ -3387,7 +3408,11 @@ static const struct net_device_ops rtw_cfg80211_monitor_if_ops = {
33873408
};
33883409
#endif
33893410

3411+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0))
3412+
static int rtw_cfg80211_add_monitor_if(_adapter *padapter, char *name, unsigned char name_assign_type, struct net_device **ndev)
3413+
#else
33903414
static int rtw_cfg80211_add_monitor_if(_adapter *padapter, char *name, struct net_device **ndev)
3415+
#endif
33913416
{
33923417
int ret = 0;
33933418
struct net_device* mon_ndev = NULL;
@@ -3418,6 +3443,9 @@ static int rtw_cfg80211_add_monitor_if(_adapter *padapter, char *name, struct ne
34183443
mon_ndev->type = ARPHRD_IEEE80211_RADIOTAP;
34193444
strncpy(mon_ndev->name, name, IFNAMSIZ);
34203445
mon_ndev->name[IFNAMSIZ - 1] = 0;
3446+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0))
3447+
mon_ndev->name_assign_type = name_assign_type;
3448+
#endif
34213449
mon_ndev->destructor = rtw_ndev_destructor;
34223450

34233451
#if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,29))
@@ -3482,6 +3510,9 @@ static int
34823510
#else
34833511
char *name,
34843512
#endif
3513+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0))
3514+
unsigned char name_assign_type,
3515+
#endif
34853516
enum nl80211_iftype type, u32 *flags, struct vif_params *params)
34863517
{
34873518
int ret = 0;
@@ -3499,7 +3530,11 @@ static int
34993530
ret = -ENODEV;
35003531
break;
35013532
case NL80211_IFTYPE_MONITOR:
3533+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0))
3534+
ret = rtw_cfg80211_add_monitor_if(padapter, (char *)name, name_assign_type, &ndev);
3535+
#else
35023536
ret = rtw_cfg80211_add_monitor_if(padapter, (char *)name, &ndev);
3537+
#endif
35033538
break;
35043539

35053540
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE)
@@ -3760,16 +3795,23 @@ static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev)
37603795
#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
37613796

37623797
static int cfg80211_rtw_add_station(struct wiphy *wiphy, struct net_device *ndev,
3763-
u8 *mac, struct station_parameters *params)
3798+
const u8 *mac, struct station_parameters *params)
37643799
{
37653800
DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
37663801

37673802
return 0;
37683803
}
37693804

37703805
static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev,
3771-
u8 *mac)
3806+
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
3807+
u8 *mac) {
3808+
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0))
3809+
const u8 *mac) {
3810+
#else
3811+
struct station_del_parameters *params)
37723812
{
3813+
const u8 *mac = params->mac;
3814+
#endif
37733815
int ret=0;
37743816
_irqL irqL;
37753817
_list *phead, *plist;
@@ -3859,7 +3901,7 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev
38593901
}
38603902

38613903
static int cfg80211_rtw_change_station(struct wiphy *wiphy, struct net_device *ndev,
3862-
u8 *mac, struct station_parameters *params)
3904+
const u8 *mac, struct station_parameters *params)
38633905
{
38643906
DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
38653907

@@ -4643,6 +4685,9 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy,
46434685
#else
46444686
struct net_device *ndev,
46454687
#endif
4688+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
4689+
struct cfg80211_mgmt_tx_params *params,
4690+
#else
46464691
struct ieee80211_channel *chan,
46474692
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) || defined(COMPAT_KERNEL_RELEASE)
46484693
bool offchan,
@@ -4662,9 +4707,16 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy,
46624707
#endif
46634708
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
46644709
bool dont_wait_for_ack,
4710+
#endif
46654711
#endif
46664712
u64 *cookie)
46674713
{
4714+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
4715+
struct ieee80211_channel *chan = params->chan;
4716+
const u8 *buf = params->buf;
4717+
size_t len = params->len;
4718+
#endif
4719+
46684720
_adapter *padapter = (_adapter *)wiphy_to_adapter(wiphy);
46694721
struct rtw_wdev_priv *pwdev_priv = wdev_to_priv(padapter->rtw_wdev);
46704722
int ret = 0;

drivers/net/wireless/realtek/rtl8192cu/os_dep/osdep_service.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ void rtw_mfree2d(void *pbuf, int h, int w, int size)
790790
rtw_mfree((u8 *)pbuf, h*sizeof(void*) + w*h*size);
791791
}
792792

793-
void _rtw_memcpy(void* dst, void* src, u32 sz)
793+
void _rtw_memcpy(void* dst, const void* src, u32 sz)
794794
{
795795

796796
#if defined (PLATFORM_LINUX)|| defined (PLATFORM_FREEBSD)
@@ -807,7 +807,7 @@ void _rtw_memcpy(void* dst, void* src, u32 sz)
807807

808808
}
809809

810-
int _rtw_memcmp(void *dst, void *src, u32 sz)
810+
int _rtw_memcmp(const void *dst, const void *src, u32 sz)
811811
{
812812

813813
#if defined (PLATFORM_LINUX)|| defined (PLATFORM_FREEBSD)

0 commit comments

Comments
 (0)