1
0
mirror of https://github.com/abperiasamy/rtl8812AU_8821AU_linux.git synced 2025-08-16 08:34:15 +02:00

Fix compilation under Linux 4.7.0-rc (#135)

This commit is contained in:
Fjodor42 2016-06-25 05:21:28 +02:00 committed by Harshavardhana
parent f886c92b3a
commit a87576f63f

View File

@ -48,24 +48,45 @@ static const u32 rtw_cipher_suites[] = {
.flags = (_flags), \
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
#define CHAN2G(_channel, _freq, _flags) { \
.band = NL80211_BAND_2GHZ, \
.center_freq = (_freq), \
.hw_value = (_channel), \
.flags = (_flags), \
.max_antenna_gain = 0, \
.max_power = 30, \
}
#else
#define CHAN2G(_channel, _freq, _flags) { \
.band = IEEE80211_BAND_2GHZ, \
.center_freq = (_freq), \
.center_freq = (_freq), \
.hw_value = (_channel), \
.flags = (_flags), \
.max_antenna_gain = 0, \
.max_power = 30, \
}
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
#define CHAN5G(_channel, _flags) { \
.band = NL80211_BAND_5GHZ, \
.center_freq = 5000 + (5 * (_channel)), \
.hw_value = (_channel), \
.flags = (_flags), \
.max_antenna_gain = 0, \
.max_power = 30, \
}
#else
#define CHAN5G(_channel, _flags) { \
.band = IEEE80211_BAND_5GHZ, \
.center_freq = 5000 + (5 * (_channel)), \
.center_freq = 5000 + (5 * (_channel)), \
.hw_value = (_channel), \
.flags = (_flags), \
.max_antenna_gain = 0, \
.max_power = 30, \
}
#endif
static struct ieee80211_rate rtw_rates[] = {
RATETAB_ENT(10, 0x1, 0),
RATETAB_ENT(20, 0x2, 0),
@ -157,20 +178,34 @@ void rtw_5g_rates_init(struct ieee80211_rate *rates)
);
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
struct ieee80211_supported_band *rtw_spt_band_alloc(
enum nl80211_band band
)
#else
struct ieee80211_supported_band *rtw_spt_band_alloc(
enum ieee80211_band band
)
#endif
{
struct ieee80211_supported_band *spt_band = NULL;
int n_channels, n_bitrates;
if(band == IEEE80211_BAND_2GHZ)
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
if(band == NL80211_BAND_2GHZ)
#else
if(band == IEEE80211_BAND_2GHZ)
#endif
{
n_channels = RTW_2G_CHANNELS_NUM;
n_bitrates = RTW_G_RATES_NUM;
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
else if(band == NL80211_BAND_5GHZ)
#else
else if(band == IEEE80211_BAND_5GHZ)
{
#endif
{
n_channels = RTW_5G_CHANNELS_NUM;
n_bitrates = RTW_A_RATES_NUM;
}
@ -193,6 +228,18 @@ struct ieee80211_supported_band *rtw_spt_band_alloc(
spt_band->n_channels = n_channels;
spt_band->n_bitrates = n_bitrates;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
if(band == NL80211_BAND_2GHZ)
{
rtw_2g_channels_init(spt_band->channels);
rtw_2g_rates_init(spt_band->bitrates);
}
else if(band == NL80211_BAND_5GHZ)
{
rtw_5g_channels_init(spt_band->channels);
rtw_5g_rates_init(spt_band->bitrates);
}
#else
if(band == IEEE80211_BAND_2GHZ)
{
rtw_2g_channels_init(spt_band->channels);
@ -203,7 +250,7 @@ struct ieee80211_supported_band *rtw_spt_band_alloc(
rtw_5g_channels_init(spt_band->channels);
rtw_5g_rates_init(spt_band->bitrates);
}
#endif
//spt_band.ht_cap
exit:
@ -218,14 +265,22 @@ void rtw_spt_band_free(struct ieee80211_supported_band *spt_band)
if(!spt_band)
return;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
if(spt_band->band == NL80211_BAND_2GHZ)
#else
if(spt_band->band == IEEE80211_BAND_2GHZ)
{
#endif
{
size = sizeof(struct ieee80211_supported_band)
+ sizeof(struct ieee80211_channel)*RTW_2G_CHANNELS_NUM
+ sizeof(struct ieee80211_rate)*RTW_G_RATES_NUM;
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
else if(spt_band->band == NL80211_BAND_5GHZ)
#else
else if(spt_band->band == IEEE80211_BAND_5GHZ)
{
#endif
{
size = sizeof(struct ieee80211_supported_band)
+ sizeof(struct ieee80211_channel)*RTW_5G_CHANNELS_NUM
+ sizeof(struct ieee80211_rate)*RTW_A_RATES_NUM;
@ -293,12 +348,16 @@ static int rtw_ieee80211_channel_to_frequency(int chan, int band)
/* see 802.11 17.3.8.3.2 and Annex J
* there are overlapping channel numbers in 5GHz and 2GHz bands */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
if (band == NL80211_BAND_5GHZ) {
#else
if (band == IEEE80211_BAND_5GHZ) {
#endif
if (chan >= 182 && chan <= 196)
return 4000 + chan * 5;
else
return 5000 + chan * 5;
} else { /* IEEE80211_BAND_2GHZ */
} else { /* NL80211_BAND_2GHZ */
if (chan == 14)
return 2484;
else if (chan < 14)
@ -344,9 +403,17 @@ static int rtw_cfg80211_inform_bss(_adapter *padapter, struct wlan_network *pnet
channel = pnetwork->network.Configuration.DSConfig;
if (channel <= RTW_CH_MAX_2G_CHANNEL)
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ);
#else
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ);
#endif
else
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_5GHZ);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_5GHZ);
#else
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_5GHZ);
#endif
notify_channel = ieee80211_get_channel(wiphy, freq);
@ -518,9 +585,17 @@ void rtw_cfg80211_indicate_connect(_adapter *padapter)
u16 channel = cur_network->network.Configuration.DSConfig;
if (channel <= RTW_CH_MAX_2G_CHANNEL)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ);
#else
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ);
else
#endif
else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_5GHZ);
#else
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_5GHZ);
#endif
notify_channel = ieee80211_get_channel(wiphy, freq);
#endif
@ -3048,9 +3123,17 @@ void rtw_cfg80211_indicate_sta_assoc(_adapter *padapter, u8 *pmgmt_frame, uint f
#else /* defined(RTW_USE_CFG80211_STA_EVENT) */
channel = pmlmeext->cur_channel;
if (channel <= RTW_CH_MAX_2G_CHANNEL)
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ);
#else
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ);
#endif
else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_5GHZ);
#else
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_5GHZ);
#endif
#ifdef COMPAT_KERNEL_RELEASE
rtw_cfg80211_rx_mgmt(padapter, freq, 0, pmgmt_frame, frame_len, GFP_ATOMIC);
@ -3093,9 +3176,17 @@ void rtw_cfg80211_indicate_sta_disassoc(_adapter *padapter, unsigned char *da, u
#else /* defined(RTW_USE_CFG80211_STA_EVENT) */
channel = pmlmeext->cur_channel;
if (channel <= RTW_CH_MAX_2G_CHANNEL)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ);
#else
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ);
#endif
else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_5GHZ);
#else
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_5GHZ);
#endif
pmgmt_frame = mgmt_buf;
pwlanhdr = (struct rtw_ieee80211_hdr *)pmgmt_frame;
@ -3930,9 +4021,17 @@ void rtw_cfg80211_rx_action_p2p(_adapter *padapter, u8 *pmgmt_frame, uint frame_
indicate:
if (channel <= RTW_CH_MAX_2G_CHANNEL)
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ);
else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ);
#else
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ);
#endif
else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_5GHZ);
#else
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_5GHZ);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE)
rtw_cfg80211_rx_mgmt(padapter, freq, 0, pmgmt_frame, frame_len, GFP_ATOMIC);
@ -3967,10 +4066,17 @@ void rtw_cfg80211_rx_p2p_action_public(_adapter *padapter, u8 *pmgmt_frame, uint
DBG_871X("RTW_Rx:category(%u), action(%u)\n", category, action);
indicate:
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
if (channel <= RTW_CH_MAX_2G_CHANNEL)
freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ);
else
freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_5GHZ);
#else
if (channel <= RTW_CH_MAX_2G_CHANNEL)
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ);
else
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_5GHZ);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE)
rtw_cfg80211_rx_mgmt(padapter, freq, 0, pmgmt_frame, frame_len, GFP_ATOMIC);
@ -3997,10 +4103,17 @@ void rtw_cfg80211_rx_action(_adapter *adapter, u8 *frame, uint frame_len, const
else
DBG_871X("RTW_Rx:category(%u), action(%u)\n", category, action);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
if (channel <= RTW_CH_MAX_2G_CHANNEL)
freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ);
else
freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_5GHZ);
#else
if (channel <= RTW_CH_MAX_2G_CHANNEL)
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ);
else
freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_5GHZ);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE)
rtw_cfg80211_rx_mgmt(adapter, freq, 0, frame, frame_len, GFP_ATOMIC);
@ -5159,7 +5272,11 @@ static struct cfg80211_ops rtw_cfg80211_ops = {
#endif
};
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
static void rtw_cfg80211_init_ht_capab(struct ieee80211_sta_ht_cap *ht_cap, enum nl80211_band band, u8 rf_type)
#else
static void rtw_cfg80211_init_ht_capab(struct ieee80211_sta_ht_cap *ht_cap, enum ieee80211_band band, u8 rf_type)
#endif
{
#define MAX_BIT_RATE_40MHZ_MCS15 300 /* Mbps */
@ -5228,17 +5345,30 @@ void rtw_cfg80211_init_wiphy(_adapter *padapter)
/* if (padapter->registrypriv.wireless_mode & WIRELESS_11G) */
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
bands = wiphy->bands[NL80211_BAND_2GHZ];
if(bands)
rtw_cfg80211_init_ht_capab(&bands->ht_cap, NL80211_BAND_2GHZ, rf_type);
}
#else
bands = wiphy->bands[IEEE80211_BAND_2GHZ];
if(bands)
rtw_cfg80211_init_ht_capab(&bands->ht_cap, IEEE80211_BAND_2GHZ, rf_type);
}
#endif
/* if (padapter->registrypriv.wireless_mode & WIRELESS_11A) */
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
bands = wiphy->bands[NL80211_BAND_5GHZ];
if(bands)
rtw_cfg80211_init_ht_capab(&bands->ht_cap, NL80211_BAND_5GHZ, rf_type);
}
#else
bands = wiphy->bands[IEEE80211_BAND_5GHZ];
if(bands)
rtw_cfg80211_init_ht_capab(&bands->ht_cap, IEEE80211_BAND_5GHZ, rf_type);
}
#endif
}
/*
@ -5307,10 +5437,17 @@ static void rtw_cfg80211_preinit_wiphy(_adapter *padapter, struct wiphy *wiphy)
wiphy->cipher_suites = rtw_cipher_suites;
wiphy->n_cipher_suites = ARRAY_SIZE(rtw_cipher_suites);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
/* if (padapter->registrypriv.wireless_mode & WIRELESS_11G) */
wiphy->bands[NL80211_BAND_2GHZ] = rtw_spt_band_alloc(NL80211_BAND_2GHZ);
/* if (padapter->registrypriv.wireless_mode & WIRELESS_11A) */
wiphy->bands[NL80211_BAND_5GHZ] = rtw_spt_band_alloc(NL80211_BAND_5GHZ);
#else
/* if (padapter->registrypriv.wireless_mode & WIRELESS_11G) */
wiphy->bands[IEEE80211_BAND_2GHZ] = rtw_spt_band_alloc(IEEE80211_BAND_2GHZ);
/* if (padapter->registrypriv.wireless_mode & WIRELESS_11A) */
wiphy->bands[IEEE80211_BAND_5GHZ] = rtw_spt_band_alloc(IEEE80211_BAND_5GHZ);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38) && LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0))
wiphy->flags |= WIPHY_FLAG_SUPPORTS_SEPARATE_DEFAULT_KEYS;
@ -5414,9 +5551,13 @@ void rtw_wdev_free(struct wireless_dev *wdev)
pwdev_priv = wdev_to_priv(wdev);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
rtw_spt_band_free(wdev->wiphy->bands[NL80211_BAND_2GHZ]);
rtw_spt_band_free(wdev->wiphy->bands[NL80211_BAND_5GHZ]);
#else
rtw_spt_band_free(wdev->wiphy->bands[IEEE80211_BAND_2GHZ]);
rtw_spt_band_free(wdev->wiphy->bands[IEEE80211_BAND_5GHZ]);
#endif
wiphy_free(wdev->wiphy);
rtw_mfree((u8*)wdev, sizeof(struct wireless_dev));